Here is my code below :
User_Info.Add(!string.IsNullOrEmpty(Request.UserAgent) ? Request.UserAgent : string.Empty);//4:UserAgent
HttpBrowserCapabilities browser = Request.Browser;
User_Info.Add(!string.IsNullOrEmpty(browser.Browser) ? "Name : " + browser.Browser + " | " +
"Type : " + browser.Type + " | " +
"MajorVersion : " + browser.MajorVersion + " | " +
"MinorVersion : " + browser.MinorVersion : string.Empty);//5:UserBrowser
What is the difference between Request.UserAgent and Request.Browser?
I couldn't understand those UserAgent strings!
Would you please show some examples with explanation?
The User Agent is used to identify the client and operating system etc.
In simple words, it's a string of text that is unique for each software or browser on the internet and holds the technical information about your device and operating system. User-agent is present in the HTTP headers when the browser wants to connect with the webserver.
AppleWebKit/537.36 indicates what browser rendering engine is used. A rendering engine is what transforms HTML into an interactive webpage on the user's screen.
“A device fingerprint, machine fingerprint, or browser fingerprint is information collected about a remote computing device for the purpose of identification. Fingerprints can be used to fully or partially identify individual users or devices even when cookies are turned off.”
UserAgent gives you a raw string about the browser. It might look like this:
User Agent :: Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.1; .NET CLR 1.0.2914)
Request.Browser will give you HttpBrowserCapabilities object which will have browser version information along with some extra information regarding the capabilities of the browser. For example:
Look at the following sample code:
HttpBrowserCapabilities bc = Request.Browser;
Response.Write("<p>Browser Capabilities:</p>");
Response.Write("Type = " + bc.Type + "<br>");
Response.Write("Name = " + bc.Browser + "<br>");
Response.Write("Version = " + bc.Version + "<br>");
Response.Write("Major Version = " + bc.MajorVersion + "<br>");
Response.Write("Minor Version = " + bc.MinorVersion + "<br>");
Response.Write("Platform = " + bc.Platform + "<br>");
Response.Write("Is Beta = " + bc.Beta + "<br>");
Response.Write("Is Crawler = " + bc.Crawler + "<br>");
Response.Write("Is AOL = " + bc.AOL + "<br>");
Response.Write("Is Win16 = " + bc.Win16 + "<br>");
Response.Write("Is Win32 = " + bc.Win32 + "<br>");
Response.Write("Supports Frames = " + bc.Frames + "<br>");
Response.Write("Supports Tables = " + bc.Tables + "<br>");
Response.Write("Supports Cookies = " + bc.Cookies + "<br>");
Response.Write("Supports VB Script = " + bc.VBScript + "<br>");
Response.Write("Supports JavaScript = " + bc.JavaScript + "<br>");
Response.Write("Supports Java Applets = " + bc.JavaApplets + "<br>");
Response.Write("Supports ActiveX Controls = " + bc.ActiveXControls + "<br>");
Response.Write("CDF = " + bc.CDF + "<br>");
For comparing browser version against a user agent, you would have to use string operations (Contains), whereas in case of Request.Browser
you can compare against a property.
Request.Browser is different from Request.UserAgent. UserAgent gets the raw user agent string of the client browser, and Request.Browser gets you the information about the browser capabilities. You wont get all the browser capabilities with the UserAgent string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With