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
2
votes
2 answers

Fire event after user is authenticated - windows authentication

Is there an event that fires after user is authenticated (Windows)? I am executing at Application_Start(), but it returns false User.Identity.IsAuthenticated. What I would like is to create and add roles manually to a user.
2
votes
2 answers

Cache or Application variable to store list of objects?

In my application, I read some xml files into a list of objects (List) but I want to avoid having to hit the file system on each request. The data in the xml files rarely changes, so I'd like to cache it in some way. Either loading the data…
Brian David Berman
  • 7,514
  • 26
  • 77
  • 144
2
votes
2 answers

Can't get profile data in Application_Start

I have the following code at some point in Application_Start MembershipUserCollection users = Membership.GetAllUsers(); foreach (MembershipUser u in users) { ProfileBase profile = ProfileBase.Create(u.UserName, false); if (profile["Index"]…
aikixd
  • 506
  • 5
  • 16
1
vote
1 answer

Cmd window to close after opening process with .bat

I'm new with batch file and the code I'm using I had to find but it always opens cmd but doesn't close it after the program is open. I'm aware that it doesn't close because it's a window process and cmd doesn't close until after the window is…
1
vote
1 answer

Are these variables being garbage collected?

I am trying to get Quartz.net scheduler to work, but I don't know why it is not firing for jobs scheduled at a future date. I have tested with a cron trigger that fires every minute and it works (job and all), so I know it isn't a problem with my…
chobo
  • 31,561
  • 38
  • 123
  • 191
1
vote
1 answer

Sending web request from global.asax (Application_Start() method)

I have pretty weird question. In my ASP.NET MVC application I defined 1 Timer which is ticking every X minutes for purpose of doing some repeating task. First of all I know that this is not best practice, but for my demo I cannot use task…
rjovic
  • 1,207
  • 2
  • 16
  • 37
1
vote
2 answers

ASP.NET application_start event fired

I am working on an ASP.NET application and caching some reference data. The code to create the cache is invoked in the application_start event in global.asax. My problem is that the application_start event is being invoked multiple times which slows…
klone
  • 2,005
  • 2
  • 16
  • 18
1
vote
8 answers

What's the best way to load highly re-used data in a .net web application

Let's say I have a list of categories for navigation on a web app. Rather than selecting from the database for every user, should I add a function call in the application_onStart of the global.asax to fetch that data into an array or collection…
Mike
  • 5,181
  • 3
  • 25
  • 19
1
vote
2 answers

ASP.NET MVC 3 + Unity injection of the Controller

Which event is the best for registering the types with Unity? I wish to do this iocContainer.RegisterType(); iocContainer.RegisterType(); so they could be retrieved by the ControllerFactory from the Unity…
1
vote
1 answer

asp.net application start fire multiple times

I have an ASP.NET 4 application written in c# in visual studio 2010. I start a timer in application_start in Global.asax and I want it to start once but after logging application behavior I have noticed that application_start fires multiple times.…
nima
  • 6,566
  • 4
  • 45
  • 57
1
vote
1 answer

Alternative to getting ServerVariables from Request

I have my webservice running on IIS in Integrated mode. In this mode, HttpContext.Request throws exception, when is called from Application_Start method. // app is HttpApplication var serverName =…
Tschareck
  • 4,071
  • 9
  • 47
  • 74
1
vote
1 answer

Why would IIS "start" an App that is still running?

We have an ASP.NET (3.5 SP1) application running on IIS7 / Windows 2008. We trap Application_Start and Application_End events in Global.asax. We also host WCF services in the app and trap the OnOpening and OnClosing events via a…
1
vote
1 answer

How to detect that the application start failed?

Our Situation: We have several webservers behind a loabalancer (Astaro Security Gateway). On the webservers we run an asp.net application and we have customerrorpages configured for 404 and 500 status codes. Now when the Application fails to start…
Thomas
  • 2,137
  • 1
  • 17
  • 38
1
vote
0 answers

Automapper configurations missings

I've been struggling for some days now with quite a strange problem. I registered some Automapper mappings in a static class like so: public static class AutomapperConfig { public static void Configure() { Mapper.CreateMap
1
vote
1 answer

Unmanaged DLL is loading before Application_Start

I've got a web app that needs to use an unmanaged DLL file. I'm trying to use the solution suggested on this related question. The problem that I'm encountering is that the unmanaged DLL is trying to be loaded before the Application_Start of my…
Richard West
  • 2,166
  • 4
  • 26
  • 40