Illegal characters in path depending on User-Agent?

无人久伴 提交于 2019-12-04 07:43:00

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://msdn.microsoft.com/en-us/magazine/dn342866.aspx

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);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!