Mobile device is detected as non mobile device

拈花ヽ惹草 提交于 2019-12-07 03:42:07

问题


I've included a mobile web form in my asp.net project, I thought that it could/should be seen just for my mobile users but I realize that it can also be seen from any browser, I don't see problem there cause I could diff the access using HttpBrowserCapabilities.IsMobileDevice=true and transferring to the appropiate aspx page, but it results that when I access to the web form from my mobile device it is identified as IsMobileDevice = false and sends me to another page.

How could it be possible that?

The mobile device runs Pocket PC 2003.


回答1:


Some are not recognized, because the UserAgent has been messed with or a new browser is being used. Such as Opera Mobile 9.5. To fix this you need to create a Browser (*.browser) file specifically for defining this. I had to do it for the new Mozilla based UserAgent that is being sent from Google.




回答2:


IMHO: The value of HttpContext.Current.Request.Headers("User-Agent") is a much safer bet as it actually indicates the browser that is making the request, and not the type of device per-se.

I've learnt from experience that if a smart phone makes a request through a third-party browser to your service, more-often-than-not any sort of "what type of device are you" test (HttpCapabilitiesBase.IsMobileDevice and/or HttpContext.Current.Request.Browser.IsMobileDevice) will fail.

Unfortunately though, short of a big list of allowed user-agents (or disallowed user-agents for that matter), you'll just have to make sure it doesn't start with Mozilla, iPhone or Opera before you render the page...

It's a hard arena to play in.
Good luck.




回答3:


I think you should use other DDR better than Microsoft Browser Capabilities. I´m using http://wurfl.sourceforge.net>WURFL, it is open source and maybe it is more extended and updated. There is other commercial DDRs like DeviceAtlas.

There is many some .net libraries but i´m using Marg.Wurfl. It allows to rendering web mobile page using wurfl capabilities.



来源:https://stackoverflow.com/questions/13224/mobile-device-is-detected-as-non-mobile-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!