Analyzing the site access terminal type (mobile terminal side or pc) method (rpm)

To find a site is opened on a mobile device or open the pc web browser, we can have the following integrated several ways to get:

Analyzing analyzed by determining whether the specific information Request.UserAgent because UserAgent contains a lot of information, so we can be judged according to certain information which is specific is determined as follows:

(1)string strUserAgent = Request.UserAgent.ToString().ToLower();
 
if (strUserAgent != null){
 
  if (Request.Browser.IsMobileDevice == true || strUserAgent.Contains("iphone") ||  
  strUserAgent.Contains("blackberry") || strUserAgent.Contains("mobile") ||  
  strUserAgent.Contains("windows ce") || strUserAgent.Contains("opera mini") ||  
  strUserAgent.Contains("palm")){
     Response.Redirect("DefaultMobile.aspx");
  }
}
 2)((System.Web.Configuration.HttpCapabilitiesBase)Request.Browser).IsMobileDevice
 3)public static boolean choose(String userAgent){        
                Agent.indexOf("WapI") > -1 || // Ericsson WapIDE 2.0   
                userAgent.indexOf("MC21") > -1 || // Ericsson MC218   
                userAgent.indexOf("AUR") > -1 || // Ericsson R320   
                userAgent.indexOf("R380") > -1 || // Ericsson R380   
                userAgent.indexOf("UP.B") > -1 || // UP.Browser   
                userAgent.indexOf("WinW") > -1 || // WinWAP browser   
                userAgent.indexOf("UPG1") > -1 || // UP.SDK 4.0   
                userAgent.indexOf("upsi") > -1 || //another kind of UP.Browser   
                userAgent.indexOf("QWAP") > -1 || // unknown QWAPPER browser   
                userAgent.indexOf("Jigs") > -1 || // unknown JigSaw browser   
                userAgent.indexOf("Java") > -1 || // unknown Java based browser   
                userAgent.indexOf("Alca") > -1 || // unknown Alcatel-BE3 browser (UP based)   
                userAgent.indexOf("MITS") > -1 || // unknown Mitsubishi browser   
                userAgent.indexOf("MOT-") > -1 || // unknown browser (UP based)   
                userAgent.indexOf("My S") > -1 ||// unknown Ericsson devkit browser   
                 userAgent.indexOf("WAPJ") > -1 ||//Virtual WAPJAG www.wapjag.de   
                userAgent.indexOf("fetc") > -1 ||//fetchpage.cgi Perl script from www.wapcab.de   
                userAgent.indexOf("ALAV") > -1 || //yet another unknown UP based browser   
                userAgent.indexOf("Wapa") > -1 || //another unknown browser (Web based "Wapalyzer")   
                userAgent.indexOf("Oper") > -1){
       return true;
   } else{
       return false;
   }
 4)if (HttpContext.Current.Request.Headers["user-agent"] != null && HttpContext.Current.Request.Headers["user-agent"].ToLower().ToString().IndexOf("mozilla") != -1){
                  HttpContext.Current.Response.Redirect("http://www. "); //PC
         }else{
                HttpContext.Current.Response.Redirect("http://wap "); //Mobile ClientTypeTesting.
         }

Of course, we also can be judged according to the resolution and screen size of the device is a mobile device or pc equipment, but the accuracy is relatively low.

Youku site is to be judged by Ip address of the network, if the mobile network, the browser will jump to 3GP website you visit the site, otherwise jump to PC sites.

Annex: modify the Browser User-Agent method Summary

IE 

  1. Modify IE's UserAgent need to edit the registry.
  2. "HKEY_CURRENT_USER"Software"Microsoft"Windows"CurrentVersion"Internet Settings"5.0"User Agent"Post Platform"
  3. "HKEY_LOCAL_MACHINE"SOFTWARE"Microsoft"Windows"CurrentVersion"Internet Settings"User Agent"Post Platform"
  4. "HKEY_LOCAL_MACHINE"SOFTWARE"Microsoft"Windows"CurrentVersion"Internet Settings"5.0"User Agent"Post Platform"
  5. To modify the IE FireFox UserAgent is to be done:
  6. Default UserAgent changed to "Firefox", while the new string value "Firefox" in the following Post Platform = "", attention needs to restart IE modified.

FireFox

  1. In the address bar, enter "about: config", press Enter to enter the setup menu.
  2. Find "general.useragent.override", if not this one, then right-click "New" -> "string", enter this string.
  3. Set the value to UserAgent you want.

Maxthon

Toolbar "Tools" -> "travel Setup Center" -> "Advanced Options", check the "custom UserAgent string", wrote the following on his UserAgent can remember. After the restart Maxthon to save the settings to take effect.


Chrome

  1. Method One: When you start adding parameters: - user-agent = "your own UserAgent".
  2. Method Two: Modify chrome.dll. The inside of a string of suspected UserAgent instead of their own.

Safari

  1. The menu bar "Edit" -> "Preferences" -> "Advanced", check the "Show Develop menu in menu bar".
  2. The menu bar will be more of a "Develop", you can set your own UserAgent through the inside of the "User Agent" submenu.

Reproduced in: https: //www.cnblogs.com/JoannaQ/p/3154011.html

Guess you like

Origin blog.csdn.net/weixin_34109408/article/details/93056455