Changed to use Authenticate asp.net event instead of Authorize
[castle.git] / Samples / MonoRail / BinderSample / BinderSample.Web / global.asax.cs
blob2f51c8756bccef48c0f4b48f751af7a0aa99b3c6
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace BinderSample.Web
17 using System;
18 using System.Web;
20 using Castle.ActiveRecord;
21 using Castle.ActiveRecord.Framework;
22 using Castle.ActiveRecord.Framework.Config;
24 using Model;
26 public class MyHttpApplication : System.Web.HttpApplication
28 public MyHttpApplication()
32 protected void Application_Start(Object sender, EventArgs e)
34 IConfigurationSource source = ActiveRecordSectionHandler.Instance;
36 ActiveRecordStarter.Initialize( source, typeof(Book), typeof(Publisher));
38 ActiveRecordStarter.GenerateCreationScripts("../schema.sql");
40 // ActiveRecordStarter.CreateSchema();
43 protected void Session_Start(Object sender, EventArgs e)
47 protected void Application_BeginRequest(Object sender, EventArgs e)
49 HttpContext.Current.Items.Add( "nh.sessionscope", new SessionScope() );
52 protected void Application_EndRequest(Object sender, EventArgs e)
54 SessionScope scope = (SessionScope) HttpContext.Current.Items["nh.sessionscope"];
56 try
58 if (scope != null) scope.Dispose();
60 catch(Exception ex)
62 HttpContext.Current.Trace.Warn( "Error", "Problems with the session:" + ex.Message, ex );