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

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


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

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


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