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
1
vote
2 answers

get keydown on application/form load in vb.net

I want to able to hold a key down while the application is loading and depending on which is being held down a certain form is shown. For example holding down shift and the opening itunes opens a little dialog allowing you set the library(or…
Jonathan.
  • 53,997
  • 54
  • 186
  • 290
1
vote
2 answers

Access HttpContext in Application_Start ASP.NET MVC 4.0

I would like to access my host and build my bundles. I know it is not straight to access httpcontext in Application_start. Can you advise any other work around to find the Request.url.host in RegisterBundles Method Global.asax protected void…
HaBo
  • 13,999
  • 36
  • 114
  • 206
1
vote
1 answer

Register over-ridable ServiceStack service

We're using ServiceStack within a package that users install onto their Umbraco website. The tricky thing is the users need to be able to add additional methods specific to their implementation. I'm aware of the ability to pass in multiple…
Tim
  • 5,443
  • 2
  • 22
  • 26
1
vote
1 answer

"Per request" activation context ... without request

I have a repository that needs to be created per request. Now there is a singleton caching object that needs to use that repository to fill itself with data, but this object is initialized in the Application_Start event, therefore there is not…
vtortola
  • 34,709
  • 29
  • 161
  • 263
1
vote
1 answer

ASP.net beginner really confused about StaticObjects and how to declare it

I'm a beginner in ASP.net, i did some research about Application state. I know about declaring new application state inside the Application_start event. But when i looked inside MSDN library (which is not helpful at all unfortunately). I found this…
Rafael Adel
  • 7,673
  • 25
  • 77
  • 118
1
vote
1 answer

Access HtmlHelper right after it is created, and before the view

I know that i from Application_Start can ActionFilterAttribute add a custom global filter and manipulate the ModelState and what not. Is there a similar way, to access the @Html (HtmlHelper) Before it get's send to the view? The reason for this is…
0
votes
1 answer

Global.asax events not firing for IHttpHandler

I've written a C# HttpHandler in VS2010 and want to do some initialisation in the application_start() event (e.g. set up logging etc.), but for some reason it isn't firing. I've tried running against the local VS server using auto-assign port and…
LDJ
  • 6,896
  • 9
  • 52
  • 87
0
votes
1 answer

ASP .NET Application_Start Event + Connection to a DB

I have started developing a full-web application by using the ASP .NET MVC 3 framework. I am a MVC 3 beginner developer. On the server-side I am going to execute some queries to a DB. Consequently I will have to make a connection to the DB. I would…
user1139666
  • 1,687
  • 4
  • 24
  • 45
0
votes
1 answer

How to Get BootStrapper.exe work in Windows Azure?

I download bootstrapper.exe from http://bootstrap.codeplex.com/, I manage to get it work in local IIS. At Application_Start() and use Process.Start() But at Windows Azure, not work at all. I am sure file is there and no error message. but no file…
Eric Yin
  • 8,737
  • 19
  • 77
  • 118
0
votes
3 answers

ASP Pre-Caching with Application_Start Considerations

I am designing a web API which requires fast read only access to a large dataset which will be hopefully be constantly stored and ready for access. Access will be from a static class which will just do some super fast lookups on the data. So, I want…
James R
  • 651
  • 1
  • 12
  • 21
0
votes
3 answers

Create multiple text files

what would be a neat way to create multiple *.txt files on application startup i.e check if they exist if not create them. I need to create about 10 text files. Will I have to do like this for every single file: var MyFile: textfile; …
user763539
  • 3,509
  • 6
  • 44
  • 103
0
votes
0 answers

Publishing with Web Deploy causes Asp.Net Web Forms application to start and stop multiple times

I have a Web Forms application running in IIS on a Windows Server 2016 dedicated server. Whenever I publish a new version to the server via Visual Studio's Web Deploy, the remote application starts and stops multiple times, which causes various…
Cleo
  • 620
  • 2
  • 10
  • 32
0
votes
1 answer

Application_Start not behaving correctly in ASP.Net 4.0 Application

I'm stumped. I ran through all the recommendations on StackOverflow and Google... no joy. My Application_Start method is not behaving correctly in my ASP.Net 4.0 application. I can set Application variables, but not call my logging method. I can…
Ray K. Ragan
  • 107
  • 11
0
votes
1 answer

Start Application_Start again on a shared hosting?

I am on a shared hosting plan using asp.net mvc 3. In my Application_Start I start my Quartz scheduler and have some jobs run. However some don't seem to be running or something is wrong in them(but they don't seem to throw errors). I been…
chobo2
  • 83,322
  • 195
  • 530
  • 832
0
votes
2 answers

Changing Global.asax variables from IIS

Can I change access or edit the values specified in Global.asax from IIS?? The reason is that I don't have the source code and the only change we need right now is to change the connection strings (database) specified in Global.asax.vb…
Sekhar
  • 5,614
  • 9
  • 38
  • 44