简体   繁体   中英

Configure web.config to access website only using IE


I want my website to be accessed only using IE 6.0 or above. If anyone tries to access the website using any other browser I want to display a big warning message. Is it possible to configure this in web.config insted of checking via javascript. I am assuming something like in authentication we have customErrors attribute were we can set the custome error page in case of failure to authenticate the user.
Thank You.
Krishnaraj

You can use the HTTP_USER_AGENT header to see what's the browser that's submitting the request. For IE it would be like :

Mozilla/4.0 (compatible; MSIE 7.0 ; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; InfoPath.2; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)

PS: This header can be manipulated by the client and submitted to browser so it is not 100% reliable. Am curious to know why you want to restrict users to IE?

There is no direct support for this functionality. However, you could validate the browser in an implementation of IHttpHandler and register that in web.config.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM