in a controller in asp.net-mvc how can i get information about the users browser?

冷暖自知 提交于 2019-12-18 18:39:24

问题


I am logging errors on my asp.net-mvc site and I wanted to see if there is anyway to detect the users browser info (name, version, etc) as it seems like people are getting issue but its because they are using very old browser. This info would help me avoid debugging time if I know they are using a "Not supported" browser.


回答1:


You may try the Request.Browser property. It will contain pretty much everything you might need about the client browser (assuming it is sending the UserAgent header properly of course).




回答2:


You can get the supplied User Agent which gives browser information:

Request.UserAgent

There is a site which lists browser user agent strings: http://www.useragentstring.com

Other values you may be interested in.

Request.Browser.Platform
Request.Browser.Version
Request.Browser.EcmaScriptVersion


来源:https://stackoverflow.com/questions/6309865/in-a-controller-in-asp-net-mvc-how-can-i-get-information-about-the-users-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!