我怎样才能检测是否请求来自移动浏览器在我的asp.net MVC 3来了 [英] How can i detect if the request is coming from a mobile browser in my asp.net MVC 3

查看:89
本文介绍了我怎样才能检测是否请求来自移动浏览器在我的asp.net MVC 3来了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所试图实现的是简单的;在所有这些我在我的web应用程序的看法,我只有两个,我已经创建了一个移动版本为他们剃须刀意见。
所以我需要将用户重定向到这些意见,如果他们正在访问从他们的移动设备应用程序。我试图在控制水平以下,但是当我在不同的移动设备上运行我的测试也没有重定向用户: -

what i am trying to achieve is simple; Among all the view which i have in my web application, i have only two razor views that i have created a mobile version for them. so i need to redirect the users to these views if they are accessing the application from their mobile devices. i tried the following on the controller level but it did not redirect the users when i run my test on different mobile devices :-

if (Request.Browser.IsMobileDevice)
            {
                return View("MobileStudentStartAssessment");
            }
            else {
                return View("StudentStartAssessment");
            }

那么,有没有我可以跟随它可以检测出大部分移动设备的另一种方法?
谢谢

So is there another approach that i can follow which can detect most of the mobile devices? Thanks

推荐答案

您可以使用<$c$c>Request.Browser.IsMobileDevice属性。

You can use the Request.Browser.IsMobileDevice property.

这篇关于我怎样才能检测是否请求来自移动浏览器在我的asp.net MVC 3来了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆