The server determines whether the client is a mobile or PC-side

Source: Internet
Author: User

1  Public voidProcessRequest (HttpContext context)2         {3Context. Response.ContentType ="text/html";4HttpBrowserCapabilities BC =context. Request.Browser;5             //context. Response.Write ("<p>browser capabilities:</p>");6             //context. Response.Write ("Type =" + BC.) Type + "<br>");7             //context. Response.Write ("Name =" + BC.) Browser + "<br>");8             //context. Response.Write ("Version =" + BC.) Version + "<br>");9             //context. Response.Write ("Major Version =" + BC.) MajorVersion + "<br>");Ten             //context. Response.Write ("Minor Version =" + BC.) MinorVersion + "<br>"); One             //context. Response.Write ("Platform =" + BC.) Platform + "<br>"); A             //context. Response.Write ("is Beta =" + BC.) Beta + "<br>"); -             //context. Response.Write ("is Crawler =" + BC. Crawler + "<br>"); -             //context. Response.Write ("is AOL =" + BC.) AOL + "<br>"); the             //context. Response.Write ("is Win16 =" + BC. Win16 + "<br>"); -             //context. Response.Write ("is Win32 =" + BC. Win32 + "<br>"); -             //context. Response.Write ("Supports Frames =" + BC. Frames + "<br>"); -             //context. Response.Write ("Supports Tables =" + BC. Tables + "<br>"); +             //context. Response.Write ("Supports Cookies =" + BC.) Cookies + "<br>"); -             //context. Response.Write ("Supports VB Script =" + BC.) VBScript + "<br>"); +             //context. Response.Write ("Supports JavaScript =" + BC.) JavaScript + "<br>"); A             //context. Response.Write ("Supports Java Applets =" + BC. Javaapplets + "<br>"); at             //context. Response.Write ("Supports ActiveX Controls =" + BC.) ActiveXControls + "<br>"); -             //context. Response.Write ("CDF =" + BC.) CDF + "<br>"); -             //context. Response.Write (BC. supportsxmlhttp); -             //context. Response.Write (HttpContext.Current.Request.UserAgent + "<br>"); -             stringSS =HttpContext.Current.Request.UserAgent; -Context. Response.Write (ss+"<br>"); in             stringm ="Mobile"; -             intres= SS. ToLower (). IndexOf (M,0, SS. Length); to             if(res<=0) +             { -Context. Response.Write ("PC-Side"); the             } *             Else $             {Panax NotoginsengContext. Response.Write ("you're using a mobile phone."); -             } the  +  A}

The message that is submitted by the client is obtained by useragent and stored as a string;

By matching the string, if the string contains mobile, then return to the phone side, otherwise the PC-side

The server determines whether the client is a mobile or PC-side

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.