Illegal characters in path depending on User-Agent?

asp.net-web-api, fiddler, http, user-agent

Solution

In my case, the root cause was MVC's MultipleViews and DisplayMode providers. This allows MVC apps to magically pick up device-specific views; e.g. custom.cshtml customer.mobile.cshtml

This article has a good explanation of the functionality as well as details how to turn it off: https://learn.microsoft.com/en-us/archive/msdn-magazine/2013/august/cutting-edge-creating-mobile-optimized-views-in-asp-net-mvc-4-part-2-using-wurfl

I fixed this by adding Microsoft.AspNet.WebPages package to my project and adding a call to this code in my startup (application_start in global.asax or if using OWIN, the method decordated w/ OwinStartup attribute):

public static void RegisterDisplayModes()
{
    // MVC has handy helper to find device-specfic views. Ain't no body got     time for that.
    dynamic modeDesktop = new DefaultDisplayMode("") { ContextCondition = (c => { return true; }) };
    dynamic displayModes = DisplayModeProvider.Instance.Modes;
    displayModes.Clear();
    displayModes.Add(modeDesktop);
}

Problem

I have two identical calls to ASP.NET, the only difference is the User-Agent. I used Fiddler to reproduce the issue. The HTTP request line is: ``` PUT http://localhost/API/es/us/havana/club/tickets/JiWOUUMxukGVWwVXQnjgfw%7C%7C214 HTTP/1.1 ``` Works with: ``` User-Agent: Mozilla/5.0 (Linux; Android 4.3; Nexus 10 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2307.2 Safari/537.36 ``` Fails with: ``` User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4 ``` Everything else is 100% the same.

Original source

Related problems