ExtensionlessUrlHandler and “Recursion too deep; t

2019-02-06 13:13发布

问题:

I'm trying to get a fellow developer's app working on my machine. Solution is built in VS 2015 using Web API and I'm running it using 64-bit IIS Express. Every request is returning 500.0 errors. Request tracing log says this about it:

1517.  -MODULE_SET_RESPONSE_ERROR_STATUS 
ModuleName    ManagedPipelineHandler 
Notification  EXECUTE_REQUEST_HANDLER 
HttpStatus    500 
HttpReason    Internal Server Error 
HttpSubStatus 0 
ErrorCode     Recursion too deep; the stack overflowed. (0x800703e9) 
ConfigExceptionInfo

The relevant config section looks like this:

<system.webServer>
<handlers>
  <remove name="OPTIONS" />
  <remove name="OPTIONSVerbHandler" />
  <remove name="TRACEVerbHandler" />
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*" verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>

Other possibly relevant facts:

  • The machine hasn't been used for web hosting before, but I've been doing a lot of VS2013 development and only installed 2015 last week to run this project.
  • The project does contain some C# 6.0 features, namely the new string interpolation goodies.

How would I even begin to debug this? I'm getting zero relevant hits on Google.

回答1:

Change path="*" to path="*." in each of the handlers you have listed.

<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />

I believe there is a way to use path="" but I haven't figured out what it is. I just ran across this question because I was trying to use path="" and that's when the "recursion too deep..." error was thrown.



回答2:

I had the exact same issue when migrating my projects to VS2017 (Was working in VS2010) and managed to resolve this by following the recommendation from another post:

https://stackoverflow.com/a/29370225

So the issue is that the IISExpress uses a different handler name (without the "Handler" postfix) from IIS, so you will need to add the following removal scripts to the web.config instead:

<!--Handler in IIS-->
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit"/>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit"/>
<remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
<!--Handler in IISExpress-->
<remove name="ExtensionlessUrl-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrl-Integrated-4.0" />

Hopefully this helps.