Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: .NET
Expertise: Advanced
Jul 31, 2017

Ensuring Application_Start Event Fires with the Next Request After a Failure

ASP.NET websites need some static data to be initialized, so that subsequent requests can utilize the loaded data and load much faster. It is a common practice to write such code in the Application_Start Event in Global.asax.cs file.

protected override void Application_Start(object sender, EventArgs e)

However, the Application_Start event could fail for a numerous reasons. One of them could be the non-availability of a dependent resource, or if you have lined up a set of synchronous steps to build some cache data and one of them failed. To overcome this limitation, use a try-catch block and call the HttpRuntime's UnloadAppDomain method in the catch block. This will ensure that the Application_Start event fires with the next request.

catch (Exception ex)
{
               HttpRuntime.UnloadAppDomain();
}
Srinath M S
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date