-1

First off, let me start by saying that I'm talking about a development server here. So with all due respect, please refrain from any "you shouldn't do that to your customers"-type of answers or comments. It is duly noted, and I never would.

According to this web article, it should never be necessary to reset/restart (is there a difference?) an IIS server for configuration changes to take hold:

IIS 7.0+ is designed to automatically pick up configuration changes. This happens whenever you deploy a new website, change website bindings, or modify any other server-level configuration. IIS automatically applies your changes to:

  • Web.config (application level): IIS triggers a restart of the affected application.

The section I'm talking about actually includes a table instead of a bullet list, and goes through all the different possible config. changes and what IIS does when they happen. However, I find their supposition about the type of change mentioned to be an absolute load of poppy cock IME (at least on a dev server).

It is often the case that while developing, I will change something in my app's Web.config and make a typo, or just blatantly get it wrong, and all of a sudden IIS falls over. Every attempt to correct the mistake will result in a <30 ms page reload time, and the exact same ASP.NET error page. So my "rusty hammer" (as those people call it) is the iisreset command.

But as they mention further up and in this related article, it is an ancient and (usually) excessive tool for the job that can supposedly be done by application pool recycling:

Bottom line: It is never necessary to use IISRESET to pick up configuration changes. For complete details on this, see the Make sure IIS has picked up the website, application pool, or configuration changes section in the reset, restart, and recycle IIS guide.

And that last sentence links back to the first article. But app pool recycling never works for me in the specific scenario that I've described!

So I completely understand the explanation of why it's bad, and don't want to use iisreset anymore, but I feel as though I have no choice. Is this true, or is there a better command that I could be using?

PS: I've read Access denied trying to run IISReset logged in as a local aministrator and Brondahl's answer to it, and that's what actually led me to the two articles above. So I'm tempted to use the workaround that they all mention, but after reading the history of iisreset and why it should probably be removed IMHO, I would really rather something succinct and not excessive.

Kenny83
  • 103
  • 6
  • 2
    Instead of making changes to running `web.config`, I would make changes to a copy of the file, then validate the file with https://stackoverflow.com/questions/68260818/how-do-i-validate-an-iis-web-config-in-powershell/68260819#68260819 for example, and then once validation is good, then copy it over. Fix the root cause, not the symptoms... – Tero Kilkanen Sep 17 '22 at 09:42
  • I develop against IIS every day and never have to use `iisreset.exe`, last time must be at in the 2003 server days. I just fix the typo in the web.config and reload the page, it works. Soft way to reload the web.config from the command line, is changing something in it. Hard way would be to recycle the app pool or kill the w3sp.exe for the AppPool, all easily done from the command line. `iisreset.exe` affects the whole server and it hardly ever needed. – Peter Hahndorf Sep 17 '22 at 17:32
  • @PeterHahndorf OK I guess I'm just making up wild lies for the fun of it then. Or maybe there's something else going on under the hood. I don't know. All I know is that what I've reported has happened to me 1000 times over the past few months. Anyway, I'll try taking Tero Kilkanen's advice next time I need to.. That should hopefully fix it. – Kenny83 Sep 18 '22 at 20:41

1 Answers1

0

I put these commands in a batch file (NT Command Script) to stop and restart IIS.

@echo off
echo.
echo Stopping Web Server
echo.
net stop w3svc
echo.
net stop iisadmin
echo.
sleep 5000
echo.
echo Starting Web Server
echo.
net start iisadmin
echo.
net start w3svc
echo.
pause
exit
CB_Ron
  • 338
  • 2
  • 10