Showing posts with label IIS. Show all posts
Showing posts with label IIS. Show all posts

2015-01-07

Really resetting IIS

If you are developing ASP.Net web sites with IIS on your local machine it's not very uncommon to update libraries and sometimes IIS just gets messed up, something along the lines of "Could not load file of assembly...".

My recipe for this kind of issues is usually something like:

  • clean + rebuild from Visual Studio
  • iisreset
If that doesn't work, then I might get desperate and do this:
  • iisreset /stop
  • delete the web site from IIS Manager
  • delete the "bin" and "obj" folders for the project
  • restart Visual Studio
  • restart Windows
  • leave the room and start over (!)
But today, I've remembered that somewhere in between, it might be useful to delete the Temporary ASP.NET files, thanks to StackOverflow.

So, why not automatize this in a batch file? Here the prototype for my "really_clean_iis.bat":
@echo off

echo stopping IIS...
iisreset /stop

rem del %TEMP%\Temporary ASP.NET Files\*.*

echo deleting temporary ASP.NET files for .NET 2.0/4.0 32/64 bit...
del C:\Windows\Microsoft.NET\Framework\v2.0.50727\"Temporary ASP.NET Files"\*.* /s /q
del C:\Windows\Microsoft.NET\Framework\v4.0.30319\"Temporary ASP.NET Files"\*.* /s /q
del C:\Windows\Microsoft.NET\Framework64\v2.0.50727\"Temporary ASP.NET Files"\*.* /s /q
del C:\Windows\Microsoft.NET\Framework64\v4.0.30319\"Temporary ASP.NET Files"\*.* /s /q

echo starting IIS..
iisreset /start

2012-09-07

Could not load file or assembly ...


If you ever caught the infamous error:

Server Error in '/ws' Application.

Could not load file or assembly 'App_Web_6sedkqth, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

And application pool recycling, site restart or even the good old iisreset won't fix it, then it might be a problem with ASP.NET temporary files.

The solution is stopping IIS (alternatively, you can just stop a specific application pool):

iisreset /stop

Deleting all the files (or part of them, if just stopped a specific application pool) from the following directory:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

And restart IIS:

iisreset /start

Note: this is basically a repost from my previous blog.