Recently, have been using Jquery-mobile + MVC to do mobile web, some experience, experience
Here's how to deny a computer access to a mobile website
The browser of the computer, not the same as the browser core of the phone, this is my idea of setting the Deny access.
Here's a way I've encapsulated a denial of access
1 Public Static classIsMobileDevice2 {3 /// <summary>4 ///whether to access the phone5 /// </summary>6 /// <param name= "Struseragent" >get models, browsers, and more</param>7 /// <returns>true is phone access; false not mobile Access</returns>8 Public Static BOOLIsMobile (stringstruseragent)9 {Ten if(Struseragent! =NULL) One { A if(System.Web.HttpContext.Current.Request.Browser.IsMobileDevice = =true|| -Struseragent.contains ("iphone") || -Struseragent.contains ("BlackBerry") || theStruseragent.contains ("Mobile") || -Struseragent.contains ("Windows CE") || -Struseragent.contains ("Opera Mini") || -Struseragent.contains ("Palm") || +Struseragent.contains ("mobi") || -Struseragent.contains ("Nokia") || +Struseragent.contains ("Samsung") || AStruseragent.contains ("SonyEricsson") || atStruseragent.contains ("mot") || -Struseragent.contains ("LG") || -Struseragent.contains ("HTC") || -Struseragent.contains ("J2ME") || -Struseragent.contains ("UCWeb") - ) in return true; - Else to return false; + } - Else the return false; * } $}
View Code
The following is a test page in MVC
Through Request.useragent, you can get the full proxy string of the current client, I am currently using the Google Browser, can see into my own definition of an error page
You can then test successfully using Android and Apple access.
In the mobile site, due to the layout, and so on, completely different from the PC, so need to filter, I hope this simple method can help you.