Changed to use Authenticate asp.net event instead of Authorize
[castle.git] / Samples / MindDump / Castle.Applications.MindDump.Web / MindDumpHttpApplication.cs
blobf714114ead42393d2a459abca021c58300758701
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 Castle.Applications.MindDump.Web
17 using System;
18 using System.Web;
20 using Castle.Windsor;
22 using NHibernate;
25 public class MindDumpHttpApplication : HttpApplication, IContainerAccessor
27 private static readonly String DefaultSessionFactory = "nhibernate.sessfactory.default";
29 private static WindsorContainer container;
31 public MindDumpHttpApplication()
33 // this.BeginRequest += new EventHandler(OnBeginRequest);
34 // this.EndRequest += new EventHandler(OnEndRequest);
37 // public void OnBeginRequest(object sender, EventArgs e)
38 // {
39 // ISessionFactory sessFac = (ISessionFactory) container[ typeof(ISessionFactory) ];
41 // ISession session = sessFac.OpenSession();
43 // SessionManager.Push(session, DefaultSessionFactory);
45 // HttpContext.Current.Items.Add( "nh.session", session );
46 // }
48 // public void OnEndRequest(object sender, EventArgs e)
49 // {
50 // ISession session = (ISession) HttpContext.Current.Items["nh.session"];
52 // if (session == null) return;
54 // try
55 // {
56 // SessionManager.Pop(DefaultSessionFactory);
58 // session.Dispose();
59 // }
60 // catch(Exception ex)
61 // {
62 // HttpContext.Current.Trace.Warn( "Error", "EndRequest: " + ex.Message, ex );
63 // }
64 // }
66 public void Application_OnStart()
68 container = new MindDumpContainer();
71 public void Application_OnEnd()
73 container.Dispose();
76 #region IContainerAccessor implementation
78 public IWindsorContainer Container
80 get { return container; }
83 #endregion