Search code examples
webformsasp.net-4.0iis-8.5isapi-rewrite

asp.net 4 Webform application with custom urlrewrite fails on IIS 8


We had some ASP.NET 3.5 and ASP.NET 4 webform websites with Custom UrlRewrite which programmatically map SEO friendly urls (http://example.com/key/This-is-sample-text-in-url.html) to physical address (http://example.com/key.aspx)

These websites worked perfect in IIS 6 with C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll for 3.5 and c:\windows\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll for 4.0 in application extension mapping window.

after migrating to windows 2012 all 3.5 websites work using classic .NET 3.5 AppPool and this statement in handlers section:

  <remove name="ASP.Net-ISAPI-Wildcard" />
  <add name="ASP.Net-ISAPI-Wildcard" path="*"
  verb="*" type="" modules="IsapiModule"
  scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll"
  resourceType="Unspecified"
  requireAccess="None"
  allowPathInfo="false"
  preCondition="classicMode,runtimeVersionv2.0,bitness64"
  responseBufferLimit="4194304" />

I expected using the same Classic .NET 4.0 AppPool and the following handler should work but didn't:

  <remove name="ASP.Net-ISAPI-Wildcard" />
  <add name="ASP.Net-ISAPI-Wildcard" path="*"
  verb="*" type="" modules="IsapiModule"
  scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll"
  resourceType="Unspecified"
  requireAccess="None"
  allowPathInfo="false"
  preCondition="classicMode,runtimeVersionv4.0,bitness64"
  responseBufferLimit="4194304" />

I still get HTTP Error 404.0 - Not Found
Module: IIS Web Core
Notification: MapRequestHandler
Handler: StaticFile
Error Code: 0x80070002

I cant downgrade website and couldn't find anything useful to find the source of error. Site log file do not provide any details, no errors in event logs.

I suspected there may be a conflict in handler mappings and tried to disable irrelevant or suspicious entries via Web.Config but there was no change. I don't know but maybe ASP.Net-ISAPI-Wildcard is not able to catch the request and finally process ends up with StaticFile handler, though in ordered list, ASP.Net-ISAPI-Wildcard is on top and StaticFile is the last.

I appreciate if anybody has a solution to this.

p.s. in the sample above target page works i.e. url to (http://example.com/key.aspx)


Solution

  • Solved

    This is in case anybody face the same situation

    The handler I added was correct, but only for 64bit applications, so when I added 32 bit version of handler problem solved. As I had set Any Platform in configuration Manager I didn't think this may be a platform matter.

      <remove name="ASP.Net-ISAPI-Wildcard" />
      <add name="ASP.Net-ISAPI-Wildcard" path="*"
      verb="*" type="" modules="IsapiModule"
      scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll"
      resourceType="Unspecified"
      requireAccess="None"
      allowPathInfo="false"
      preCondition="classicMode,runtimeVersionv4.0,bitness64"
      responseBufferLimit="4194304" />
    
      <remove name="ASP.Net-ISAPI-Wildcard-32" />
      <add name="ASP.Net-ISAPI-Wildcard-32" path="*"
      verb="*" type="" modules="IsapiModule"
      scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll"
      resourceType="Unspecified"
      requireAccess="None"
      allowPathInfo="false"
      preCondition="classicMode,runtimeVersionv4.0,bitness32"
      responseBufferLimit="4194304" />