Ci sono e lib di .NET là fuori che interpreteranno le stringhe di user agent memorizzate e daranno un bel oggetto fortemente tipizzato con le informazioni contenute?lib di .NET per l'interpretazione delle stringhe di user agent
risposta
È possibile utilizzare la proprietà HttpRequest.Browser se è la stessa di cui si desidera la stringa dell'agente utente. Prova a programmare i tuoi siti web contro le funzionalità del browser invece delle versioni del browser.
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>");
Sto lavorando da un registro delle stringhe di user agent. C'è un modo per utilizzare HttpBrowserCapabilities per analizzare una stringa di utente (lunga) dopo la richiesta http? –
Forse puoi creare un httprequest e quindi impostare le intestazioni dalla stringa dell'agent e funzionerà in questo modo, non l'ha testato. – Stefan
var browserCapabilities = new HttpBrowserCapabilities
{
Capabilities = new Hashtable { { string.Empty, userAgent } }
};
var capabilitiesFactory = new BrowserCapabilitiesFactory();
capabilitiesFactory.ConfigureBrowserCapabilities(new NameValueCollection(), browserCapabilities);
return browserCapabilities;
Si potrebbe provare questo ua-parser sembra essere aggiornato abbastanza spesso!
http://www.hanselman.com/blog/TheNETFrameworkAndTheBrowsersUserAgentString.aspx – pm100
Controlla questo collegamento - Spero che questo ti aiuti - http://blogs.msdn.com/b/ie/archive/2005/04/27/ 412813.aspx –
Controlla questo link: [http://user-agent-string.info/download/UASparser-for-dotNET](http://user-agent-string.info/download/UASparser-for-dotNET) –