我创建了移动设备的布局 - _Layout.Mobile.cshtml 有自己的脚本,它们的样式,都可以,在平板电脑上加载完整版本的网站(_Layout.cshtml)。
在手机上加载移动版本(_Layout.Mobile.cshtml)
BUT iPads(虽然他指的是平板电脑)已加载移动版本
我该如何解决这个问题?
最佳答案
据我所知,您需要告诉 DisplayModeProvider iPad 应该获得默认显示模式(桌面 View )。
这可以通过以下代码来实现:
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode()
{
ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf("iPad", StringComparison.OrdinalIgnoreCase) >= 0)
});
该代码具有相当的解释性,您可以插入一个默认模式,其中 iPad 的上下文位于用户代理中。
在此处查看更多信息:http://www.asp.net/mvc/tutorials/mvc-4/aspnet-mvc-4-mobile-features在“浏览器特定 View ”下
这应该放在 Global.asax.cs 的 Application_Start() 方法中
关于c# - 移动设备 _Layout.Mobile.cshtml 和 iPad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21898590/