最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do i get client details in ASP.NET ie. browser, resolution and OS? - Stack Overflow

programmeradmin2浏览0评论

I need to get client stats for browser (not full long description but short names, generally firefox,ie6,ie7,ie8,safari,chrome,opera and mozilla). Client resolution and OS ie. Windows Vista, Ubuntu ....

thanks

I need to get client stats for browser (not full long description but short names, generally firefox,ie6,ie7,ie8,safari,chrome,opera and mozilla). Client resolution and OS ie. Windows Vista, Ubuntu ....

thanks

Share Improve this question asked May 24, 2010 at 7:51 eugeneKeugeneK 11.1k20 gold badges70 silver badges105 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

You can get the browser name using Request.Browser.Browser. There's also a lot more in the Request.Browser class that may be of interest:

var browserName = Request.Browser.Browser; // Would return IE, etc
var browserType = Request.Browser.Type; // Would return IE7, IE8, etc.
var browserMajor = Request.Browser.MajorVersion;
var browserMinor = Request.Browser.MinorVersion;

var supportsActiveX = Request.Browser.ActiveXControls;
var inputType = Request.Browser.InputType;
var supportsColours = Request.Browser.IsColor;
var isMobileDevice = Request.Browser.IsMobileDevice;
var supportsJavaApplets = Request.Browser.JavaApplets;
var ...

Because ASP.Net is a server side language, it has no visiblity of the client machine's OS settings. Therefor the only way to get the Client OS Resolution would be to use JS and pass the resolution back either as a URL parameter or within a hidden field:

var resolution = screen.width + ' x ' + screen.height;
hiddenField.value = resolution;
发布评论

评论列表(0)

  1. 暂无评论