Your application requires the use of a specific browser and you want to determine whether the required browser is being used before allowing a user to access your application.
Use the properties of the
to determine the browser type and version, and then take the action
required by your application.
In the code-behind class for the page, use the .NET language of your choice to:
Browser property of the
Request.Browser object to return a string
representing the full browser type, such as
“IE” in the case of Internet
Version property of the
Request.Browser object to return a string that
represents the major and minor version of the browser, such as
“6.0” in the case of IE 6.0.
Take action accordingly, such as outputting a message indicating whether the user’s browser is compatible with the application.
Example 18-10 through Example 18-12 show the
.aspx file and
the VB and C# code-behind files for an application that demonstrates
the solution. The output of our example program is shown in Figure
Figure 18-2. Determining the user’s browser
With the variety of different browsers in use today and the significant variation in their capabilities, it is not uncommon to need to determine the type of browser being used. Then, based on the browser, you may need to inform the user ...