Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get .net to handle all requests in IIS7

Tags:

iis

iis-7

I had an application that was running on IIS 6. All requests went through aspnet_isapi.dll. This was achieved via a wildcard application mapping (which did not verify the file existed).

I have copied said application to a machine running IIS7, and would like to get it working again.

In the application, any request with an extension of .aspx (or .ashx) are handled in the normal way. Other requests with different extensions (such as .html and .xml) are handled by a custom http module. Some requests have no extension, and are dynamically redirect to a file with an extension (e.g. visiting …/item/1 might redirect to …/item/1.html or …/item/1.xml, depending on values in the accept header).

The new location probably does not exist, but a response is generated dynamically.

Currently, the application pool is in “classic” mode, and is using .NET v4.0 (it was previously using .NET 3.5, but that doesn’t seem to be related to the problem). The custom http module is set only in the web.config.

The redirect (from …/item/1 to …/item/1.html) seems to work, which suggests that extension less requests are indeed being processed by the application (that redirect is written in the application itself). I think that means that the custom module is working.

Requests with extensions (.html, .xml etc) are failing however. The error I get is:

HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

Module: IIS Web Core
Notification: MapRequestHandler
Handler: StaticFile
Error Code: 0x80070002

I have tried: Adding a wildcard script mapping that mapped * to aspnet_isapi.dll Tried adding a specific mapping for *.html to aspnet_isapi.dll

These still result in the same error message, and still seem to go to the handler "StaticFile".

I tried modifying "StaticFile" so that it uses the aspnet_isapi.dll executable, and this results in a new error:

HTTP Error 404.4 - Not Found
The resource you are looking for does not have a handler associated with it.
Handler: Not yet determined

Any help would be greatly appreciated.

like image 929
zod Avatar asked Dec 22 '22 00:12

zod


1 Answers

Set application pool in integrated mode and set that all request run all managed modules

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true">
  ...
  </modules>
  ...
</system.webServer>
like image 140
Antonio Bakula Avatar answered Dec 23 '22 13:12

Antonio Bakula