路径中的非法字符取决于User-Agent? [英] Illegal characters in path depending on User-Agent?
问题描述
我对ASP.NET有两个相同的调用,唯一的区别是User-Agent。我用Fiddler重现了这个问题。
I have two identical calls to ASP.NET, the only difference is the User-Agent. I used Fiddler to reproduce the issue.
HTTP请求行是:
PUT http://localhost/API/es/us/havana/club/tickets/JiWOUUMxukGVWwVXQnjgfw%7C%7C214 HTTP/1.1
使用:
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
失败:
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
其他是100%相同。
推荐答案
在我的情况下,根本原因是MVC的MultipleViews和DisplayMode提供者。这允许MVC应用程序神奇地获取特定于设备的视图;例如
custom.cshtml
customer.mobile.cshtml
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
本文对功能有一个很好的解释,以及如何关闭它的详细信息:
https://msdn.microsoft.com/en-us/magazine /dn342866.aspx
This article has a good explanation of the functionality as well as details how to turn it off: https://msdn.microsoft.com/en-us/magazine/dn342866.aspx
我通过将Microsoft.AspNet.WebPages包添加到我的项目并在我的启动中添加对此代码的调用来修复此问题(application_start in global.asax或者如果使用OWIN,该方法使用OwinStartup属性进行解析):
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);
}
这篇关于路径中的非法字符取决于User-Agent?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!