asp.net-mvc – 用于移动设备的displaymode,带有桌面视图,适用于
发布时间:2020-12-16 06:25:24 所属栏目:asp.Net 来源:网络整理
导读:嗨,我有一个MVC 3应用程序,最近转换为mvc 4并添加了移动视图.我想为iPad专门为平板电脑添加桌面视图的移动显示模式(主要来自此处的流量). 我在我的代码中就是这样的 DisplayModeProvider.Instance.Modes.Insert(0,new DefaultDisplayMode() { ContextConditi
嗨,我有一个MVC 3应用程序,最近转换为mvc 4并添加了移动视图.我想为iPad专门为平板电脑添加桌面视图的移动显示模式(主要来自此处的流量).
我在我的代码中就是这样的 DisplayModeProvider.Instance.Modes.Insert(0,new DefaultDisplayMode() { ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf("iPad",StringComparison.OrdinalIgnoreCase) >= 0) }); DisplayModeProvider.Instance.Modes.Insert(1,new DefaultDisplayMode("Mobile") { ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf("Mobile",StringComparison.OrdinalIgnoreCase) >= 0) }); 并设置输出缓存changebycustom如下所示 public override string GetVaryByCustomString(HttpContext context,string custom) { string strUserAgent = context.Request.UserAgent.ToLower(); if (strUserAgent.Contains("ipad")) { return base.GetVaryByCustomString(context,custom); } if (Request.Browser.IsMobileDevice) { return "mobile"; } return base.GetVaryByCustomString(context,custom); } 我在移动设备和桌面设备上都使用相同的网址. 问题: 任何人都可以帮助我,我错了.我甚至关闭了outputcache仍然是同样的问题. 解决方法
这是一个已知问题,我们最近发布了针对MVC 4:
http://nuget.org/packages/Microsoft.AspNet.Mvc.FixedDisplayModes的解决方法NuGet包.
解决方法是简单地将此NuGet包安装到您的项目中.但是,如果您的应用程序自定义已注册视图引擎的集合,则应确保引用 Microsoft.Web.Mvc.FixedRazorViewEngine 要么 Microsoft.Web.Mvc.FixedWebFormViewEngine 而不是默认的视图引擎实现. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc-3 – 在MVC Razor View中使用If语句
- asp.net – 具有一个无效的SelectedValue,因为它在项目列表
- asp.net的ftp的上传和下载
- 如何为新项目决定WebForms vs ASP.NET MVC 3?
- asp.net – 为什么WebMethod声明为静态?
- asp.net-mvc – 从Asp.net MVC发送HTML电子邮件的最佳方式是
- asp.net-mvc – Html.EditorFor SelectList
- asp.net – 如何设置Thread.CurrentPrincipal以在整个应用程
- asp.net – 如何集成ASP .Net Model View Presenter(MVP)模
- WCF服务与ASP.NET Web Api
推荐文章
站长推荐
- asp.net – mvc渲染没有httpContext或控制器上下
- asp.net-core – 是否可以将NoSQL用于Identity S
- asp.net – 将MVC 2项目升级到MVC 5
- asp.net-mvc-3 – 自定义错误适用于HttpCode 403
- asp.net-mvc – 如何使用ASP.NET MVC 2在NHibern
- asp.net-mvc – 什么是应用程序洞察遥测(未配置)
- 这个ASP.NET功能在哪里记录? <%= string forma
- .net – 为什么UseAuthentication必须在.NET Cor
- asp.net-mvc – ServiceStack和MVC4没有连线
- asp.net-mvc-3 – 从MVC 3中使用Razor View引擎的
热点阅读