ASP.NET suddenly wants a trailing slash

In an ASP.NET application, we have plenty (think, several dozen) of controller classes like this:

[RoutePrefix("some/thing/1.0")]
public class SomeController : ApiController
{
    [HttpGet]
    [Route("")]
    public string GetInfo()
    {
        return "hello world";
    }

    [HttpPut]
    [Route("")]
    public void StoreInfo(string info)
    {
        // ...
    }
}

This has been working fine for some weeks, without any issues. We could call those endpoints as follows:

GET https://myWebApp/client/some/thing/1.0

Now, with yesterday’s nightly build, this has stopped working. Suddenly, we can only access those URLs with a trailing slash, i.e.

GET https://myWebApp/client/some/thing/1.0/

This applies to parametrized queries, as well:

GET https://myWebApp/client/some/thing/1.0?x=42

doesn’t work anymore, but

GET https://myWebApp/client/some/thing/1.0/?x=42

does.

As the last working build is just one day back, I have scanned the commit history of our source control, and I have compared the build packages side by side. I was not able to find any change that seemed to be related to this issue.

Moreover, this is definitely related to some change in our application: I could reproduce the issue on my local copy of the application exactly after updating my binaries to those of yesterday’s build. (Note that another build has been created this morning, and the issue is still there. So, it’s not that yesterday’s build was broken in some way; whatever has changed seems to be permanent.)

What could have changed and where else could I go looking for it?

Or, asked more proactively:

Where can I change this behaviour?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

We have found the concrete cause of why the error started appearing now:

A call to MapSignalR had been commented out, and without it, a much older, presumably erroneous setting buried somewhere in the application’s configuration files became active:
A TransferRequestHandler whose path was specified as *. instead of just *.

Presumably, SignalR somehow overwrites that setting once initialized, so the issue never popped up for the past couple of years.

So, explicitly: The Web.config file contained the following line:

<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>

This had to be changed to

<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*" verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>

for the issue described here to go away.

(Unfortunately, this solution causes another problem.)


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x