ExtensionlessUrlHandler and "Recursion too deep; the stack overflowed" - asp.net-web-api

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.

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.

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.

Related

After uninstalling WebDav on Windows Server 2016 it pops back to life after a day

We host an API that needs PUT/DELETE verbs to interact and this thing keeps coming up.
At first i figured out I need to ditch webdav to fix the 405 error and went for the solutions described here: "405 method not allowed" in IIS7.5 for "PUT" method
I removed handler, module and edited web.config
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
<remove name="WebDAV" />
<remove name="BundleModule" />
<add name="BundleModule" type="System.Web.Optimization.BundleModule" />
<remove name="TelemetryCorrelationHttpModule" />
<add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="integratedMode,managedHandler" />
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
Now the tricky part: I removed webDav with the add/remove Feature and completly deinstalled it and thats it for the day.
But when I login the server and test the verbs on the next day, the error is back and the feature is back installed on the server. I checked the log files for reboots and updates and found nothing peculiar.
Has anyone any idea what I am doing wrong? Any hints are much apprecicated.

Inconsistent ASP.NET Web Api Pre-flight OPTIONS

I'm getting an inconsistent preflight HTTP Options request from my single page app. This only happens randomly sometimes and the only way I ameliorate the issue is by pressing F5 and things are good for a while until I kind of go "idle" for a little bit.
When it happens my Chrome Network Tab looks like this:
When my
https://webui.myapp.com (AngularJS 1.1.5)
https://api.myapp.com (ASP.NET Web Api .NET v4.5 on IIS 7)
My infrastructure breakdown
AngularJS Application
ASP.NET Web Api
Visual Studio 2012
IIS 7.5
Windows 7
I've read a few articles and my web.config's system.webServer looks like this:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="false">
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
<remove name="OPTIONSVerbHandler"/>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" 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="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" 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="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Max-Age" value="1728000"/>
</customHeaders>
</httpProtocol>
</system.webServer>

.Net Web API No HTTP resource was found that matches the request URI

I am working on .Net Web API which is working fine in debug as well as on localhost IIS but when i publish this to server it starts giving following error :-
"Message": "No HTTP resource was found that matches the request URI
On server, we have application folder under default site for this API, but it's working fine in application folder under local IIS's default site so that should not be the problem.
Now i tried setting proper verb in handler as specified in following url but didn't work:
HTTP 404 Page Not Found in Web Api hosted in IIS 7.5
Also i have MVC4 installed on server as suggested on following url:
.NET Web Api - 404 - File or directory not found
Also WebDav module, handler may give error so i also tried removing it but it's giving same error.
Here is the Web.config section for module, handler settings :-
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<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>
I am not playing with routes anywhere. Am i missing something regarding settings/configuration in web.config or server IIS ?
This works for me:
<remove name="WebDAV"/>
I don't know why it is installed on the server. But this seems to have interference with extensionless handlers
From IIS (http://www.iis.net/learn/install/installing-publishing-technologies/installing-and-configuring-webdav-on-iis):
Microsoft released a new WebDAV extension module that was completely
rewritten for Internet Information Services (IIS) 7 and above on
Windows ServerĀ® 2008. This new WebDAV extension module incorporated
many new features that enable Web authors to publish content better
than before, and offers Web administrators more security and
configuration options. Microsoft has released an update to the WebDAV
extension module for Windows ServerĀ® 2008 that provides shared and
exclusive locks support to prevent lost updates due to overwrites.
Another potential reason for this is if the
GlobalConfiguration.Configure(WebApiConfig.Register);
is after
RouteConfig.RegisterRoutes(RouteTable.Routes);
in global.asax.cs
It needs to be before, otherwise the default RouteConfig route 'eats' the WebAPI route - and attempts to map API requests to a controller called API...
Change to:
<validation validateIntegratedModeConfiguration="false" />
<modules>
<remove name="WebDAVModule"/>
</modules>
<handlers>
<remove name="WebDAV"/>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" 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="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" 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="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>

MVC-Mini-Profiler - Web Forms - 'MiniProfiler' is undefined

I tired to install the MiniProfiler, using the HowTo on http://miniprofiler.com/
This seems to work:
<%= StackExchange.Profiling.MiniProfiler.RenderIncludes() %>
But when I start the site, I get this error message:
'MiniProfiler' is undefined
The problem is in the included MiniProfiler code:
var initMp = function(){
load('/mini-profiler-resources/includes.js?v=6cJT7lsVkH6SxAlFpQstk1/AgtUwMUApXN3pviVvaRE=',function(){
MiniProfiler.init({.....
When I try open http://localhost/mini-profiler-resources/includes.js?v=6cJT7lsVkH6SxAlFpQstk1/AgtUwMUApXN3pviVvaRE= with IE I get an 404.
I even tried this Solution found on stackoverflow but it did not work for me :(
Does anybody know this problem, or know what I can do to fix that?
SOLUTION
I solved the problem by adding the config section from this solution and the "runAllManagedModulesForAllRequests" line:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<handlers>
<add name="UrlRoutingModule1" path="mini-profiler*.js" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
<add name="UrlRoutingModule2" path="mini-profiler*.css" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
<add name="UrlRoutingModule3" path="mini-profiler*.tmpl" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
The "trick" was to add the line below to get the handlers to work.
<modules runAllManagedModulesForAllRequests="true"/>
You should be able to avoid this issue a bit more concisely (one handler line instead of three) by adding the following to your main web.config file:
<system.webServer>
...
<handlers>
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>

Telerik RadControls setup issue

I just ran the Telerik update wizard for Teleriks RadControls for ASP.NET because for some reason my web.config was not setup to run RadControls. It modified my web.config. I am not getting the following error:
ASP.NET Ajax client-side framework failed to load.
If i revert my web.config back to the backup i get this error:
'~/Telerik.Web.UI.WebResource.axd' is missing in web.config. RadScriptManager requires a HttpHandler registration in web.config. Please, use the control Smart Tag to add the handler automatically, or see the help for more information: Controls > RadScriptManager
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: '~/Telerik.Web.UI.WebResource.axd' is missing in web.config. RadScriptManager requires a HttpHandler registration in web.config. Please, use the control Smart Tag to add the handler automatically, or see the help for more information: Controls > RadScriptManager
If i refrain from using the RadScriptManager and revert back to using a normal ScriptManager, my project works fine. Except on some pages when i operation is performed i receive the following error:
Sys.InvalidOperationException: A control is already associated with the element.
The above error was why i attempted to us the RadScriptManager in the first place...
Has anyone run into this issue before and perhaps know what is going on?
D
the handler is not registered correctly. Click on the smart tag of the RadScriptManager and choose "register"
or copy the settings from this web.config file (.net45)
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="Telerik.ScriptManager.TelerikCdn" value="Disabled" />
<add key="Telerik.StyleSheetManager.TelerikCdn" value="Disabled" />
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
<pages>
<controls>
<add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" />
</controls>
</pages>
<httpHandlers>
<add path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" validate="false" />
<add path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" validate="false" />
<add path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" validate="false" />
<add path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" validate="false" />
<add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
</httpHandlers>
<httpModules>
<add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule" />
<add name="RadCompression" type="Telerik.Web.UI.RadCompression" />
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="RadUploadModule" />
<add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule" preCondition="integratedMode" />
<remove name="RadCompression" />
<add name="RadCompression" type="Telerik.Web.UI.RadCompression" preCondition="integratedMode" />
</modules>
<handlers>
<remove name="ChartImage_axd" />
<add name="ChartImage_axd" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" preCondition="integratedMode" />
<remove name="Telerik_Web_UI_SpellCheckHandler_axd" />
<add name="Telerik_Web_UI_SpellCheckHandler_axd" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" preCondition="integratedMode" />
<remove name="Telerik_Web_UI_DialogHandler_aspx" />
<add name="Telerik_Web_UI_DialogHandler_aspx" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" preCondition="integratedMode" />
<remove name="Telerik_RadUploadProgressHandler_ashx" />
<add name="Telerik_RadUploadProgressHandler_ashx" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" preCondition="integratedMode" />
<remove name="Telerik_Web_UI_WebResource_axd" />
<add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" preCondition="integratedMode" />
</handlers>
</system.webServer>
</configuration>

Resources