Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 618
eugeneK Avatar asked May 24 '10 07:05

eugeneK


1 Answers

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;
like image 186
djdd87 Avatar answered Sep 19 '22 01:09

djdd87