c# – MVC 4移动和平板电脑视图分离

我正在尝试为平板电脑和移动设备制作单独的视图.在app_start我有这个代码
displayModeProvider.Instance.Modes.Insert(0,new
        DefaultdisplayMode("Tablet")
        {
            ContextCondition = (ctx =>
            ctx.Request.UserAgent.IndexOf("iPad",StringComparison.OrdinalIgnoreCase) >= 0 ||
            ctx.Request.UserAgent.IndexOf("Android",StringComparison.OrdinalIgnoreCase) >= 0)
        });

我创建了两个布局文件,一个用于移动设备,另一个用于平板电脑.但是当我从Android上的移动设备访问时存在冲突.它将我重定向到layout.tablet.我怎么能分开这两个设备?

解决方法

我在浏览器中使用用户代理切换器对此进行了测试,它运行正常.
displayModeProvider.Instance.Modes.Insert(0,StringComparison.OrdinalIgnoreCase) >= 0 && 
            ctx.Request.UserAgent.IndexOf("mobile",StringComparison.OrdinalIgnoreCase) < 1)
        });

        displayModeProvider.Instance.Modes.Insert(1,new DefaultdisplayMode("Mobile")
        {
            ContextCondition = (ctx =>
                ctx.Getoverriddenbrowser().IsMobileDevice)
        });

相关文章

原文地址:http://msdn.microsoft.com/en-us/magazine/cc163...
前言 随着近些年微服务的流行,有越来越多的开发者和团队所采...
最近因为比较忙,好久没有写博客了,这篇主要给大家分享一下...
在多核CPU在今天和不久的将来,计算机将拥有更多的内核,Mic...
c语言输入成绩怎么判断等级
字符型数据在内存中的存储形式是什么