I'm working on the mvcForum project (on codeplex) and want to remove as much code as possible from the global.asax file - mostly to make it easier to integrate mvcForum into existing ASP.NET MVC application without changing too much code.
I need to hook into the application events to be able to set the correct CultureInfo (depending on the users' choice etc) and other things.
This isn't a problem with this in the global.asax file:
protected void Application_PostAuthorizeRequest() {
// Some code here!
}
But when I try moving the code somewhere else, the event never happens. What I'm doing is this:
public MVCForumBootstrapper(HttpApplication app) {
app.PostAuthorizeRequest += new EventHandler(app_PostAuthorizeRequest);
}
And this in the global.asax
protected void Application_Start() {
var strapper = new MVCForumBootstrapper(this);
}
I was kind of expecting this to work in exactly the same way?
What am I doing wrong/have I missed?
Thanks, Steen
You should do this in the
Init
method of Global.asax. InApplication_Start
it's too late too hook events: