如何检测片(任何)要求? [英] How to detect tablet(any) requests?

查看:100
本文介绍了如何检测片(任何)要求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 如果(Request.Browser.IsMobileDevice)
 {
     的Response.Redirect(/手机/ Login.htm);`
 }

要检测的手机,但相同的时候,它检测平板,如移动,我需要的函数,检查是否有平板电脑或函数检查设备屏幕的大小。

感谢S的工作,我用ScreenPixelsWidth和ScreenPixelsHeight这是code。如果任何需要它

  INT怀特= Request.Browser.ScreenPixelsWidth;
                INT高度= Request.Browser.ScreenPixelsHeight;                如果(Request.Browser.IsMobileDevice&安培;&放大器;怀特< 720安培;&安培;高度< 1280)
            {
               的Response.Redirect(/手机/ Login.htm);
            }


解决方案

您可以使用ScreenPixelsWidth和ScreenPixelsHeight(<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.httpbrowsercapabilities.aspx\">http://msdn.microsoft.com/en-us/library/system.web.httpbrowsercapabilities.aspx)你可以定义你考虑是否定期或移动版本应呈现的阈值。

有更多的方法来解决这个问题,但既然你已经在使用的HttpBrowserCapabilities类,你还不如用这2个属性。

 if (Request.Browser.IsMobileDevice)
 {
     Response.Redirect("/mobile/Login.htm");`
 }

To detect mobiles but same times it detect Tablet like mobile, i need function that check if there Tablet or function that check the size of screen of the device.

Thank"s that work i used ScreenPixelsWidth and ScreenPixelsHeight this is the code if any need it

 int wight = Request.Browser.ScreenPixelsWidth;
                int height = Request.Browser.ScreenPixelsHeight;

                if (Request.Browser.IsMobileDevice && wight < 720 && height<1280)
            {
               Response.Redirect("/mobile/Login.htm");
            }

解决方案

You can use ScreenPixelsWidth and ScreenPixelsHeight (http://msdn.microsoft.com/en-us/library/system.web.httpbrowsercapabilities.aspx) and you can define a threshold in which you consider whether the regular or the mobile version should be rendered.

There are many more ways to tackle this issue but since you are already using the HttpBrowserCapabilities class, you might as well use these 2 properties.

这篇关于如何检测片(任何)要求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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