Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question 开发者_开发技巧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?
var browserCapabilities = new HttpBrowserCapabilities
{
Capabilities = new Hashtable { { string.Empty, userAgent } }
};
var capabilitiesFactory = new BrowserCapabilitiesFactory();
capabilitiesFactory.ConfigureBrowserCapabilities(new NameValueCollection(), browserCapabilities);
return browserCapabilities;
You could try this ua-parser it seems to be updated fairly often!
Edit: It seems ua-parser is more or less dead now, DeviceDetector.NET seems to be in active development.
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>");
精彩评论