Select the product you need help with
How to determine browser type in server-side code without the BrowserType object in ASP.NETArticle ID: 306576 - View products that this article applies to. This article was previously published under Q306576 On This PageSUMMARY
This step-by-step article demonstrates how to determine the client browser type in server-side code without using the BrowserType object in ASP.NET. In classic Microsoft Active Server Pages (ASP), the two most common methods to determine the client browser type are to use the BrowserType component or the Request.ServerVariables("HTTP_USER_AGENT") variable. Although you can use these methods in ASP.NET, you can also use the new properties that ASP.NET provides. In ASP.NET, the Request object includes a property named Browser that contains rich information about client browser capabilities such as browser name, browser version, and whether JavaScript, ActiveX controls, cookies, and frames are supported. NOTE: This article assumes that you have ASP.NET and Visual Studio .NET installed on your computer. Using the HTTP_USER_AGENT Header to Determine the Browser VersionIn ASP.NET, you can access the Request.ServerVariables collection or use the new Request.UserAgent property to retrieve the HTTP_USER_AGENT header value. You can parse this string to determine the browser name, the major and minor versions of the browser, and if the browser is a beta release.The following list includes two sample user agent strings:
272413
(http://support.microsoft.com/kb/272413/
)
How to determine browser type in server-side script without the BrowserType object
Using the Request.Browser Object to Determine the Browser VersionIn ASP.NET, the Request object contains a property named Browser that returns an object of type HttpBrowserCapabilities. This object contains properties such as browser, version, major version, and minor version that you can use to determine the client browser type.Follow these steps to create a simple ASP.NET application using Visual Basic .NET that writes the browser name and versions back to the client browser in HTML:
PropertiesArticle ID: 306576 - Last Review: December 27, 2005 - Revision: 3.5
| Article Translations
|


Back to the top








