IIS 7 doesn’t do a 301 redirect

asp.netiis-7

I have just migrated some sites to IIS7 from IIS6, and am experiencing problems with one of the sites.

When a request comes in for the site (www.ourdomain.com/site1/) with a trailing slash everything is fine. But if the trailing slash is left out (www.ourdomain.com/site1), then the request fails.

Apparently it doesn't do a 301 redirect on the slashl-less URL, resulting in ASP.NET throwing an exception. This is not happening with the other sites at the same domain.

What can be the cause of this?

EDIT:
The exception I get is this:
System.Web.HttpException: Failed to Execute URL.
at System.Web.Hosting.
ISAPIWorkerRequestInProcForIIS6.BeginExecuteUrl(String url, String method, String childHeaders, Boolean sendHeaders, Boolean addUserIndo, IntPtr token, String name, String authType, Byte[] entity, AsyncCallback cb, Object state)
at System.Web.HttpResponse.BeginExecuteUrlForEntireResponse(String pathOverride, NameValueCollection requestHeaders, AsyncCallback cb, Object state)
at System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Best Answer

Can you give more details about the error you are getting? My first guess is that the StaticFile handler mapping is not present (or not configured properly). In the Handler Mappings setup, you should have a Module Mapping with the following settings:

name: StaticFile
path: *
type: StaticFileModule,DefaultDocumentModule,DirectoryListingModule

Request Restrictions:
mapping: invoke on file or folder
verbs: all
access: read

If this is the problem, you would be getting a 404.4/not found error, with sub error "the resource you are looking for does not have a handler associated with it"

Related Topic