How can I block all mobile phones from accessing my website

后端 未结 2 2010
孤城傲影
孤城傲影 2021-01-17 06:30

I\'m in the process of building an ASP.Net/C# site on IIS 7.5 and I would like to block all mobile phones from accessing this website.

How can I block/deny access

相关标签:
2条回答
  • 2021-01-17 06:58

    You will likely have to use an IIS module (like URL Rewrite v2) and do something like this: http://forums.iis.net/t/1169853.aspx

    Look at the request blocking feature.

    0 讨论(0)
  • 2021-01-17 07:04

    Your only hope it to check for the User-Agent header property on the HTTP request, and deny content to those User-Agents coming from mobile phones.

    Here's a list of user agents for mobile devices: http://www.zytrax.com/tech/web/mobile_ids.html

    You'll have to use the HttpResquest.UserAgent property for that: http://msdn.microsoft.com/en-us/library/system.web.httprequest.useragent.aspx

    Good luck.

    0 讨论(0)
提交回复
热议问题