Mobile Web site, set to deny computer access

Source: Internet
Author: User

Recently, I have been using Jquery-Mobile + MVC for Mobile Web. I have some experiences and experiences.

The following describes how to reject computer access to a mobile website.

The browser on the computer is different from the browser kernel on the mobile phone. This is my idea of rejecting access.

Below is a method that I have encapsulated to reject access

IsMobile (strUserAgent! = (System. web. httpContext. current. request. browser. isMobileDevice = | strUserAgent. contains () | strUserAgent. contains () | strUserAgent. contains () | strUserAgent. contains () | strUserAgent. contains () | strUserAgent. contains () | strUserAgent. contains () | strUserAgent. contains () | strUserAgent. contains () | strUserAgent. contains () | strUserAgent. contains () | strUserAgent. contains () | strUserAgent. contains () | strUserAgent. contains () | strUserAgent. contains (} View Code

Below is a test page in MVC

The Request. UserAgent can be used to obtain the complete proxy string of the current client. I am currently using a Google browser and can see an error page defined by myself.

Then, the test is successful if you use Android or apple for access.

Because of the layout and so on, the mobile website is completely different from the PC end, so you need to filter the website. I hope this simple method can help you.

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.