How to use Global.asax in Azure Web Role

You can utilize global.asax with one exception: In Application_Start event handler, you can't access the request context or work with RoleManager (other operations will be OK). This is caused IIS7's integrated mode. The workaround is to move the code to Application_BeginRequest and adopt the singleton pattern. Something like this:


protected
void Application_BeginRequest(object sender, EventArgs e)

{

object obj = Application["AlreadyProcessed"];

if (obj == null)

{

Application["AlreadyProcessed"] = true;

//Do something with the request context or RoleManager...

}

}

posted on 2009-01-13 20:22  Yang - Windows Azure  阅读(208)  评论(0编辑  收藏  举报

导航