views:

131

answers:

4

Are there and .NET libs out there that will interpret stored user agent strings and give you a nice strongly typed object with the contained information?

+1  A: 

You can use the HttpRequest.Browser property if its for that you want the user agent string. Try to program your websites against browser Capabilities instead of browser versions.

http://msdn.microsoft.com/en-us/library/system.web.httprequest.browser.aspx

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>");
Stefan
I'm working from a log of user agent strings. Is there any way to use HttpBrowserCapabilities to parse a user agent string (long) after the http request?
Mr. Flibble
Maybe you can create a httprequest and then set the headers from your agent string and it will work that way, havent tested it.
Stefan
A: 

Check this link - Hope this helps you -

http://blogs.msdn.com/b/ie/archive/2005/04/27/412813.aspx

Sachin Shanbhag
A: 

Check this link:

http://user-agent-string.info/download/UASparser-for-dotNET

Jar
Thank you Jar..
Mr. Flibble