This is a question I've always had (including in earlier versions of ASP.NET), but I'll ask here in the context of ASP.NET 5. The question is: when building an application with ASP.NET 5 we coded a Startup
class that is responsible for setting up the pipeline with a Configure
method. Anything about launching the web application is done there.
This is exactly where I am: the concept of initializing the web application. A web application does nothing on its own, it waits for requisitions to do. The doubt is: made a request the application is initialized, receives the request, sends the response and ends? Or is it initialized if it is not, processes the request, responds and waits for new requests?
How does this initialization concept work for an ASP.NET 5 web application? If it is actually initialized if it is not and wait for new requests, how does this actually work?
I made a test to see if I understood better what is happening as follows: I created a singleton class Exemplo
which has a DataInstanciado
property. After that I created a controller ExemploController
as follows:
public class ExemploController : Controller
{
[HttpGet("/api/instancia")]
public Exemplo GetInstancia()
{
return Exemplo.ObtemInstancia();
}
}
When I send a request to "/ api / instance" I received an object containing a datetime that is the date the object was created. In subsequent requests the returned object was exactly the same, with the same date. After 30 minutes, when requesting again the returned object was another, with the date of 30 minutes later.
In this way, the server seems to be keeping the application running. It looks like the objects are in memory. But I do not understand how this works. How does the life cycle of this type of application work?
EDIT : I know there is an application life cycle running in IIS, but IIS is not specifically what I'm asking. ASP.NET 5 applications use the OWIN specification and therefore can be hosted not only on IIS, but in other ways as well (such as self host). What I wanted to know is how the life cycle works, regardless of where the application is hosted.