Check For Web Browser Types

You can use the HttpBrowserCapabilities class to find out the properties of a user's Web browser. You can then use this information in your code to determine what the proper response to your client should be. Perhaps you might redirect the user to another page based on the browser type. You could also use the HttpBrowserCapabilities class for information to do custom logging that tracks what types of browsers are accessing your site.

Some sites that you build with depend on browser capabilities for making decisions on what is sent to the user of the site. For example, you might have a few pages on your site that can be enhanced with ActiveX controls. Before sending the ActiveX control in the response, you want to check to see whether the users support ActiveX controls. If they do not, you can redirect them to a page that is implemented without an ActiveX control.

To use the HttpBrowserCapabilities class, you need to create a variable of type HttpBrowserCapabilities. With this variable, you can use the Request.Browser property to return all of the information about the user's Web browser. After you have this information, you can use the property of interest. For example, the Browser property is used to determine where to send the user.

CHECK FOR WEB BROWSER TYPES

CHECK FOR WEB BROWSER TYPES

□ Open a new document ir your text editor.

< Add a pair of script delimiters.

Create a new variable of type HttpBrowserCapabilities and initialize the variable by using the Request.Browser property.

Q Create a new variable of type string and read the Web browser type property into the string.

□ Open a new document ir your text editor.

Add the page directive, set the language for the page to C#, and buffer the page.

< Add a pair of script delimiters.

Create a new variable of type HttpBrowserCapabilities and initialize the variable by using the Request.Browser property.

Q Create a new variable of type string and read the Web browser type property into the string.

Was this article helpful?

0 0

Post a comment