Questions tagged [application-start]

Application_Start method called by ASP.NET once for the lifetime of the application domain, not for each HttpApplication instance. It's called when the first resource (such as a page) in an ASP.NET application is requested.

During asp.net application life cycle, the application raises events that you can handle and calls particular methods that you can override. To handle application events or methods, you can create a file named Global.asax in the root directory of your application.

If you create a Global.asax file, ASP.NET compiles it into a class derived from the HttpApplication class, and then uses the derived class to represent the application.

An instance of HttpApplication processes only one request at a time. This simplifies application event handling because you do not need to lock non-static members in the application class when you access them. This also allows you to store request-specific data in non-static members of the application class. For example, you can define a property in the Global.asax file and assign it a request-specific value.

ASP.NET automatically binds application events to handlers in the Global.asax file using the naming convention Application_event, such as Application_BeginRequest. This is similar to the way that ASP.NET page methods are automatically bound to events, such as the page's Page_Load event. For details, see ASP.NET Page Life Cycle Overview.

The Application_Start and Application_End methods are special methods that do not represent HttpApplication events. ASP.NET calls them once for the lifetime of the application domain, not for each HttpApplication instance.

The following table lists some of the events and methods that are used during the application life cycle. There are many more events than those listed, but they are not commonly used.

http://msdn.microsoft.com/en-us/library/ms178473.aspx

89 questions
0
votes
1 answer

ASP.net publishing project is slow to start

I have a fairly large website (~75k LoC), deployed two D2 v2 machines on Azure (7GiB RAM, 2 VCPU). When I do a new build, I observe: 1 of the CPUs going to 100% This lasts for up to two minutes Then Application_Start is fired I'm trying to improve…
Tom Gullen
  • 61,249
  • 84
  • 283
  • 456
0
votes
0 answers

Process undergone before ApplicationStart method - .NET MVC Website

When I click on the "Run" option in Visual Studio of my Web application, it builds all the projects, and my browser is opened. It takes a minimum of 3 minutes for my browser window to open and to hit the breakpoint my ApplicationStart method in the…
Dinesh M
  • 1,026
  • 8
  • 23
0
votes
0 answers

IIS Recycling issue

I got an issue with IIS and recycle. I explain what we want, and what we did. What We want: we have an ASP.net WebSite, it executes a code in "Application_Start" which loads in memory a lot of data. It take few minutes. Then, we want to start the…
0
votes
1 answer

Remove black screen upon application launch

I have created a C# WPF application. In that i have limited UI components (label, MediaElement, Image sources(4)). I am loading my application with maximized window. When I launch my exe, a Black screen is shown for a second and the actual UI…
Ashish Rana
  • 135
  • 1
  • 11
0
votes
2 answers

Programmatically change StartupUri

I have two windows and dependant upon a condition I want one to be displayed, otherwise I want the other window to be displayed. this is what I have tried so far. private void Application_Startup(object sender, StartupEventArgs e) { …
Craig Martin
  • 179
  • 2
  • 15
0
votes
0 answers

Singleton object destroys in ASP.NET MVC

I need to do some updates just once after starting ASP.NET MVC application. I've created the singleton instance: public sealed class SingletonClass { private static readonly Object s_lock = new Object(); private static SingletonClass…
Vitaliy
  • 645
  • 1
  • 10
  • 21
0
votes
3 answers

Registering routes on session start not application start

I am trying to register the route collection in .net based on each session. The code I have works fine, you goto website/username and it loads the correct sub pages, but you have to restart the application to goto website/username2 to load those…
Daniel
  • 91
  • 10
0
votes
0 answers

How to call an async method to create a file on application start up

I want to create an Asp MVC application to run a code every 12 hours. This code will create a file on the server each time. So I've made an async method and called it from Application_Start event to make a schedule and It worked fine. My problem is…
0
votes
1 answer

Linux : what is the order of execution of *.desktop files in autostartup

Need to launch two application on system startup. A desktop file is created starting the fist one. Unfortunately could not find any way to launch the two application in single desktop file. If there is way please write in comments ? As a workaround…
deimus
  • 9,565
  • 12
  • 63
  • 107
0
votes
2 answers

How to best debug the creation of unwanted threads in ASP.NET web application

After an IISRESET on my public facing webserver, the initialization of my app seems correct. That is, in the Application_Start event I launch a new "email" thread whose purpose is to sleep until the configured time, upon "waking" produce a report…
0
votes
1 answer

Activity start too long

Hello I have a problem with opening Activity. I'm calling startActivity() with Intent by clicking Button. I need to wait 4-5 seconds before Activity shows up on the screen. I know how to do. itemimg = new ItemsInPacagesImageView(imglist1, this,…
0
votes
2 answers

Assign some values from MVC Application_Start to a static class

I have a requirement to show some of that database information in the layout view of my MVC application. I was thinking that if I did this in the Application_Start() method, and assigned to a static class with a static value, the view would be…
blgrnboy
  • 4,877
  • 10
  • 43
  • 94
0
votes
1 answer

Application_Start not called in global.asax. Why?

In my global.asax I have the following code: public static bool Was = false; protected void Application_Start(object sender, EventArgs e) { Was = true; } When I open a page and look at the Was variable, it's still false. What gives? (Note: the…
Vilx-
  • 104,512
  • 87
  • 279
  • 422
0
votes
2 answers

IIS: Unexpected behavior in case of unhandled exception in Application_Start

I'm using Windows 7, IIS 7.5.7600.16385 and currently .NET 4.6.1 is installed and we have a MVC application. Some days ago we had some strange behavior at our application. Unfortunately a service which is called inside Application_Start was not…
0
votes
1 answer

Bypass SonarQube naming convention rule for Application_ methods in Global.asax

Is there any way to bypass the rule "Rename this method to match the regular expression: [A-Z][a-zA-Z0-9]++" for the Global.asax.cs, specifically for the for the Application_ methods/events? We don't want to minimize the amount of files that are…
timmkrause
  • 3,367
  • 4
  • 32
  • 59