A
A
Alexander Kovalenko2020-02-20 17:50:02
IIS
Alexander Kovalenko, 2020-02-20 17:50:02

What is the behavior mechanism of AspNet Core in IIS on reboot?

Given IIS on Windows 10, it hosts a simple WebAPI test site written in Asp Net Core.
Controller method:

[HttpGet()]
[Route("api/exchange/param/{param1}")]
public Answer Param(string param, string param1)
{
    var result = new Answer
    {
        Id = ID,
        Time = DateTime.Now,
        Value = rnd
    };
    return result;
}


ID field:
private static long _id;
private static long ID
{
    get
    {
        _id++;
        return _id;
    }
}

The rnd field is similar to ID but returns a random value.

Further there is a service which once a second pulls this API. As a result, we get the following answer:
{
    "id": 163688,
    "time": "2020-02-20T16:42:10.4914933+02:00",
    "value": 728.992299050555
}

As a matter of fact, the question is that after restarting or turning off the computer (in particular, at night), id is miraculously not reset, which is logical to assume for a static field. It is not saved anywhere and is not restored in any way, it does not even have a setter. Interested in the mechanism of behavior where, how and most importantly why IIS saves the state of the process. Or a link where to read about it, unfortunately I did not find information on my own.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Kovalenko, 2020-02-20
@AlexanderKovalenko

Understood in the most interesting behavior.
If the computer was in "Sleep" before the "Shutdown" is done, the state of the processes running under IIS is saved.
If "Reboot" is performed, then everything is reloaded as expected.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question