9

For some reason, my ASP.NET web application returns error 500 (apparently originating from handler "ExtensionlessUrlHandler-Integrated-4.0") when a non-existing route is accessed.

This issue has started to occur after I had changed path="*." to path="*" in the <add name="ExtensionlessUrlHandler-Integrated-4.0" ... line of my Web.config file in order to solve another problem (failure to process routes with a dot after the last slash).

I cannot change path back to "*.", even though exactly that is suggested as a solution in another question, because that will bring back the other problem - routes with a dot in the part after the last slash are not found anymore.

Like in that linked other question, I am using OData. However, I am not aware that it should play any role in route resolution in my case at all, because I think we treat it just as an ordinary library that is referenced in our C# projects and invoked by a few of our web API endpoints.

<modules runAllManagedModulesForAllRequests="true"/> is already set in my Web.config file.

What else can I do so 404 is returned for unknown routes and "extension-ful" routes (i.e. routes whose last part after the last slash contains a dot) are accepted?

EDIT: I have managed to increase my FREB log size and now see that the offending entry is number 1346, saying

ModuleName="ManagedPipelineHandler", Notification="EXECUTE_REQUEST_HANDLER", HttpStatus="500", HttpReason="Internal Server Error", HttpSubStatus="0", ErrorCode="Rekursion zu tief, Stapelüberlauf. (0x800703e9)", ConfigExceptionInfo=""

In English, the error message means: "Recursion too deep, stack overflow."

Therefore, it appears to be the same issue as in another question, however, the answers from there do not help in my case:

  • Philip suggests to remove various handlers, which doesn't change anything for me.
  • Joe Davis suggests the solution with the "*." path, which works, but causes the other problem, as described above.

Both answers refer to the <handlers> section in my Web.config file, which currently looks like this:

<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>
O. R. Mapper
  • 20,083
  • 9
  • 69
  • 114
  • try to run the failed request tracing and get more detail about cause of the issue. https://learn.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/using-failed-request-tracing-rules-to-troubleshoot-application-request-routing-arr – Jalpa Panchal Mar 27 '20 at 03:08
  • @JalpaPanchal: I already tried that, but the log is [truncated](https://stackoverflow.com/q/60863607/1430156) before coming to the point where the error 500 is actually selected. Once I have managed to increase maximum log size, I might be able to add some additional information, although right now, I'm not quite sure yet what I'll be looking for among those hundreds of lines. – O. R. Mapper Mar 27 '20 at 08:26
  • you could try this suggested post steps to increase the maxLogFileSizeKB: https://stackoverflow.com/a/60879049/11147346. you could try to run the frt for the 500 error code. – Jalpa Panchal Mar 27 '20 at 08:35
  • @JalpaPanchal: Yes, I will, when I'm at work the nect time. – O. R. Mapper Mar 27 '20 at 08:40
  • @JalpaPanchal: I have updated the post with some information from the FREB log. It's a very long logfile and I'm not sure what to look for yet, though I'm still scanning the lines. – O. R. Mapper Mar 30 '20 at 07:23
  • the only reason behind the error message is the handler configuration. you could try to add this code in your web.config file: ` ` refer this link for more detail: https://stackoverflow.com/questions/35181260/extensionlessurlhandler-and-recursion-too-deep-the-stack-overflowed – Jalpa Panchal Mar 31 '20 at 08:29
  • @JalpaPanchal: Unfortunately, that doesn't change anything; still getting error 500, internally caused by a stack overflow due to an overly deep recursion. I had already come across that question and left a comment on one of the answers yesterday. – O. R. Mapper Mar 31 '20 at 08:51
  • did you install the .NET Extensibility feature of iis? – Jalpa Panchal Mar 31 '20 at 09:30
  • @JalpaPanchal: The platform installer says "IIS: .NET Extensibility 4.5" (apparently the latest version, from 2011) is installed. In my Windows features, the checkbox with ".NET Extensibility 4.8" is checked (".NET Extensibility 3.5" isn't, though). – O. R. Mapper Mar 31 '20 at 10:12
  • I don't think changing `*.` to `*` is a good idea. It means you changed the handler to listen to any path / url. Because the handler issues child request, so basically the child request is also caught by the handler itself causing this stack overflow issue. I think you should put the `.` back, and fix the original problem instead because it is in your code, and would be a lot easier to fix than fixing the pipeline. – weichch Apr 23 '20 at 00:10
  • @weichch: "fix the original problem instead" - ok, but [how](https://stackoverflow.com/q/60619106/1430156)? Not sure what you mean by "it is in your code"; as far as I can tell, the other problem is entirely an IIS configuration issue that occurs before any of my code gets to run, as well. – O. R. Mapper Apr 23 '20 at 05:13
  • disable "just my code" from the debug options, and enable framework stepping, make the request and quickly pause the execution go to the parallel stack trace window and have a look at what is causing the recursion, one of the stacks should be ugly long, and you should be able to see what is causing it... – L.Trabacchin Apr 23 '20 at 17:38
  • You said in the referenced question, *A call to `MapSignalR` had been commented out, and without it* which implies if you have `MapSignalR` the issue is fixed. So why not take a look what `MapSignalR` does? I created a MVC project from template, added attribute routing, and I put the example controller in, when I call `/some/thing/1.0`, I can hit the action without problem. I'm using default IIS settings. So the problem here is either with your code (e.g. how your routes registered), or with your additional IIS pipeline settings. – weichch Apr 23 '20 at 22:12
  • Note that my default IIS settings does have `ExtensionlessUrlHandler` and I also had `ExtensionlessUrlHandler` in my web.config, with `path=*.`. – weichch Apr 23 '20 at 22:15

1 Answers1

2

To make sure your web api works with '.' (dot) add a specific API handler BEFORE the global handler with path '*.'

See below example:

  <add name="ApiURIs-ISAPI-Integrated-4.0-ForApi" path="/api/*" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />