开发者

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

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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜