-
Notifications
You must be signed in to change notification settings - Fork 0
/
Global.asax.cs
90 lines (76 loc) · 2.89 KB
/
Global.asax.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Context;
using Ninject.Mvc3;
using NHWebConsole;
namespace website
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : System.Web.HttpApplication
{
/*
#region NHibernate stuff
/// <summary>
/// Create the Nhibernate Sessionfactory
/// </summary>
public static ISessionFactory SessionFactory = CreateSessionFactory();
public MvcApplication()
{
this.BeginRequest += new EventHandler(MvcApplicationBeginRequest);
this.EndRequest += new EventHandler(MvcApplicationEndRequest);
}
private static void MvcApplicationEndRequest(object sender, EventArgs e)
{
CurrentSessionContext.Unbind(SessionFactory).Dispose();
}
private static void MvcApplicationBeginRequest(object sender, EventArgs e)
{
CurrentSessionContext.Bind(SessionFactory.OpenSession());
}
private static ISessionFactory CreateSessionFactory()
{
var cfg = new Configuration().Configure(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "nhibernate.config"));
return cfg.BuildSessionFactory();
}
#endregion
*/
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
//filters.Add(new HandleErrorAttribute());
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//ignore elmah route: http://code.google.com/p/elmah/wiki/MVC
routes.IgnoreRoute("elmah.axd");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new string [] {"Website.Controllers"}
);
}
private static void ConfigureNHWebConsole()
{
/*var cfg = BuildNHibernateConfiguration();
var sessionFactory = cfg.BuildSessionFactory();
NHWebConsoleSetup.OpenSession = () => sessionFactory.OpenSession();
NHWebConsoleSetup.Configuration = () => cfg;*/
}
protected void Application_Start()
{
AppStart_NinjectMVC3.Start();
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
}
}