Answer the question
In order to leave comments, you need to log in
How can I terminate the application so that IIS Express does not start it on a new request?
There is a standard ASP.NET Core application that implements a simple REST API.
The form has an exit button.
Everything that is possible is done in the exit function))) I understand that this is wrong, but I thought at least something would help.
The problem is that after exiting, IIS starts the application again when it receives the first request.
private static void ExitApplication()
{
cancelTokenSource.Cancel();
_webHost.StopAsync(ApplicationLifetime.ApplicationStopping).Wait();
ApplicationLifetime.StopApplication();
Environment.Exit(0);
}
Answer the question
In order to leave comments, you need to log in
It's not just wrong, it's not right at all. The asp.net application is executed within the framework of the web server, in the logic of which the killing of the application is not the end of the execution. Well, this is how the web works.
Hang your application either in an isolated application based on Kestrel - which is launched by clicking on the exe file (this is not recommended, no one has tested Kestrel for vulnerabilities, it usually works under the roof of IIS, or under NGINX), or pack it into a service - for windows way.
Both cases are extremely negative. Web services are not meant for final death. It's closer to a desktop app.
PS: You won't be able to terminate the IIS Express process from within (and it will be able to resume your application). There is no such command. And never will.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question