如何阻止所有手机访问我的网站

问题描述:

我正在IIS 7.5上构建ASP.Net/C#网站,我想阻止所有手机访问该网站.

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.

如何阻止/拒绝所有类型的手机访问该网站(使用Windows身份验证)?我正在构建一个内部应用程序,我只希望使用IE的桌面才能访问它.这比任何其他事情更重要的是安全性需求.

How can I block/deny access to this website (which uses Windows Authentication) from all types of mobile phones? I'm building an internal application that I want only desktops with IE to access. This is more of a security need than anything.

理想情况下,我想先检查用户是否在任何Windows质询/响应发生之前通过手机(或仅允许使用的浏览器)访问此网站.

Ideally I would like to check to see if the user is accessing this website via mobile phone (or just approved browsers) first before any Windows challenge/response happens.

我一直在寻找Google的指针(没有运气),以及URL重写选项.由于我对Web编程这方面的知识还比较陌生,因此对于从哪里开始寻找或什至在正确的位置寻找东西,我有些茫然.我不确定是否应该只允许一个批准的浏览器通过或阻止所有手机.

I've been looking to Google for pointers (with no luck) on this as well as looking at URL Rewrite options. Since I'm relatively new to this aspect of Web Programming I'm at a bit of a loss on where to begin looking or if I'm even looking in the right places. I'm not sure if I should just allow one approved browser through or block all mobile phones.

您只希望它检查HTTP请求上的User-Agent标头属性,并拒绝来自移动电话的User-Agent的内容.

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.

以下是移动设备的用户代理列表: http://www.zytrax.com/tech/web/mobile_ids.html

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

您必须为此使用HttpResquest.UserAgent属性: http://msdn.microsoft.com/en-us /library/system.web.httprequest.useragent.aspx

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

祝你好运.