Asp.net mobile and PC recognition (Collection)

Source: Internet
Author: User
Tags perl script

1. Use useragent

 Protected   Void Page_load ( Object  Sender, eventargs e ){  //  Verification Terminal          String Agent = request. headers [ "  User-Agent  "  ];  If  (Choose_net (agent) {response. Redirect (  " /Mobile/  "  );}}  //  Verification Terminal      Public   Bool  Choose_net (string useragent ){  If (Useragent. indexof ( "  Noki  " )>- 1 | //  Nokia phones and emulators Useragent. indexof ( "  Eric  " )>- 1 | //  Ericsson WAP phones and emulators Useragent. 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. sdks 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 (  "  Ucweb  " )>- 1 | //  Another unknown browser (web based  "  Wapalyzer  "  ) Useragent. indexof (  "  Blackberry " )>- 1 | //  Another unknown browser (Web  Based  "  Wapalyzer  "  ) Useragent. indexof (  "  J2EE  " )>- 1 | //  Another unknown browser (web based "  Wapalyzer  "  ) Useragent. indexof (  "  Bytes  " )>- 1 | Useragent. indexof (  "  Android  " )>- 1 | Useragent. indexof (  " Mozilla  " )>- 1  ){  Return   True  ;}  Else  {  Return   False  ;}} 

2. Consider Asp.net MVC
There is a template for mobile.

3. Get the browser attributes

Httpbrowsercapabilities BC =Request. browser; response. Write ("<Script language = 'javascript '> alert ('"+ Bc. browser +"'); </SCRIPT>");

4. js judgment

<SCRIPT type = "text/JavaScript"> VaR Bro = Navigator. useragent;  //  Alert (BRO );          //  Alert (bro. indexof ("Windows Phone "));          // IPad browser navigator. useragent (including iPad)          If (Bro. indexof ("netfront")> 0 | bro. indexof ("ucweb")> 0 | bro. indexof ("iPhone")> 0 | bro. indexof ("Windows CE")> 0 | bro. indexof ("MIDP-2.0")> 0 | bro. indexof ("android")> 0 | bro. indexof ("Opera mini")> 0 | bro. indexof ("symbianos")> 0 | bro. indexof ("Windows Phone")> 0 ) {Window. Open ( "Wap1/index. aspx", "_ top" );}  //  Else if (bro. indexof ("Windows NT")> 0 ){          // Window. Open ("newweb/default.html", "_ top ");          //  }                  Else  {Window. Open ( "Newweb/default.html", "_ top" );} </SCRIPT>

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.