1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
20 using Castle
.ActiveRecord
;
21 using Castle
.ActiveRecord
.Framework
;
22 using Castle
.ActiveRecord
.Framework
.Config
;
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"];
58 if (scope
!= null) scope
.Dispose();
62 HttpContext
.Current
.Trace
.Warn( "Error", "Problems with the session:" + ex
.Message
, ex
);