0

在按照此链接从 MVC3 升级到 MVC4将 ASP.NET MVC 3 项目升级到 ASP.NET MVC 4后,只需要对配置文件进行一些更改,一切都作为 Web 应用程序工作,但是当我想测试它的移动设备时应用程序,我想在我的 Global.asax.cs 文件中添加类似的内容:

DisplayModes.Modes.Insert(0, new DefaultDisplayMode("iPhone")
{
  ContextCondition = (context => context.Request.UserAgent.IndexOf
                     ("iPhone", StringComparison.OrdinalIgnoreCase) >= 0)
});

但它说它在 System.Web.WebPages 中找不到 DisplayModeProvider 类!请提供任何帮助

4

1 回答 1

0

尝试这个

DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("iPhone")
{
  ContextCondition = (context => context.Request.UserAgent.IndexOf
                     ("iPhone", StringComparison.OrdinalIgnoreCase) >= 0)
});
于 2013-07-18T13:09:36.457 回答