Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to restart asp.net application besides modifying web.config

Is there a recommended way to bounce an asp.net application besides touching web.config from inside the application? is HttpRuntime.UnloadAppDomain(); the preferred way to do this ? and if so where do you do this? In the unload of a page or some other place in the application?

like image 330
MikeJ Avatar asked Jan 02 '09 18:01

MikeJ


People also ask

Can ASP NET application run without web config?

yes we can run asp.net application without web. config file,if u r not configure any settings in web. config file then it will take machine.

Do we need to restart IIS after changing web config?

Changes to the web. config will trigger the app to be reloaded by IIS as soon as there are 0 connections left to the app. You can also stop and restart the app pool that the app is assigned to in order to make this happen. You do not need to stop and restart IIS itself.

Where is asp net web config?

config file is located in the %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\ folder. The default settings that are contained in the Machine. config file can be modified to affect the behavior of Microsoft .


1 Answers

Touching web.config from inside an application is a bad idea, IMO. Also, the idea of having a file that you modify is a little hackney, IMO.

The documentation specifically states that UnloadAppDomain will shut the application down:

UnloadAppDomain allows programmatic shutdown of unused applications.

You should be able to make this call anywhere in the application. Mind you, you might get a SecurityException, so make sure that the runtime gives you the appropriate permissions (you might want to put this in a library and make a call and then set the library up in the GAC with evidence to give it full trust).

like image 58
casperOne Avatar answered Sep 22 '22 06:09

casperOne