Hi Juan,
Thanks a lot! That was very helpful!
Ashwini
Hi, Ashwini.
In ASP.NET, you can use Request.Browser to identify browser
capabilities, and redirect the user based on the results.
Here's a sample detection page.
detect.aspx:
------------------
<%@ Page Language="VB" %>
<script language="VB" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
ltlBrowserName.Text = Request.Browser.Type & ", " & Request.Browser.Platform
ltlAllData.Text = "Type = " & Request.Browser.Type & "<br>"
ltlAllData.Text &= "Name = " & Request.Browser.Browser & "<br>"
ltlAllData.Text &= "Version = " & Request.Browser.Version & "<br>"
ltlAllData.Text &= "Major Version = " & Request.Browser.MajorVersion & "<br>"
ltlAllData.Text &= "Minor Version = " & Request.Browser.MinorVersion & "<br>"
ltlAllData.Text &= "Platform = " & Request.Browser.Platform & "<br>"
ltlAllData.Text &= "Is Beta = " & Request.Browser.Beta & "<br>"
ltlAllData.Text &= "Is Crawler = " & Request.Browser.Crawler & "<br>"
ltlAllData.Text &= "Is AOL = " & Request.Browser.AOL & "<br>"
ltlAllData.Text &= "Is Win16 = " & Request.Browser.Win16 & "<br>"
ltlAllData.Text &= "Is Win32 = " & Request.Browser.Win32 & "<br>"
ltlAllData.Text &= "Supports Frames = " & Request.Browser.Frames & "<br>"
ltlAllData.Text &= "Supports Tables = " & Request.Browser.Tables & "<br>"
ltlAllData.Text &= "Supports Cookies = " & Request.Browser.Cookies & "<br>"
ltlAllData.Text &= "Supports VB Script = " & Request.Browser.VBScript & "<br>"
ltlAllData.Text &= "Supports JavaScript = " & Request.Browser.JavaScript & "<br>"
ltlAllData.Text &= "Supports Java Applets = " & Request.Browser.JavaApplets & "<br>"
ltlAllData.Text &= "CDF = " & Request.Browser.CDF & "<br>"
End Sub
</script>
<html>
<body>
Your browser is: <asp:literal id="ltlBrowserName" runat="server" />
<p>
<b><u>Here is your browser's information:</u></b><br />
<asp:literal runat="server" id="ltlAllData" />
</body>
</html>
---------------
It's very easy to redirect based on the results of Request.Browser:
Dim browserType As String = Request.Browser.Type
If browserType = "Netscape" Then
response.redirect("PageForNetscapeUsers.aspx")
End if
You could also use a Case statement to determine different redirect pages,
based on the several possibilities you're interested in, if you're interested in
creating custom pages for more than one browser.
Your custom browser pages could just be the very same page,
copied to a different filename, with the @Page directive clienttarget
set to "downlevel" :
<%@ Page ClientTarget = "downlevel" %>
That will send HTML 3.2, instead of HTML 4, output to the browser,
and should eliminate your formatting problems.
If you take a look at your machine.config file for .NET 1.1, located at
drive:\WINDOWSInstallDirectory\Microsoft.NET\Framework\v1.1.4322\CONFIG\machine.config
you'll see a lot of browser matches specified in the browserCaps section.
If you are using .NET 1.0, the file would be at
drive:\WINDOWSInstallDirectory\Microsoft.NET\Framework\v1.0.3705\CONFIG\machine.config
If you are using .NET 1.0, the file would be at
drive:\WINDOWSInstallDirectory\Microsoft.NET\Framework\v1.0.3705\CONFIG\machine.config
If you haven't modified the browserCaps section, by specifying a value for it in web.config,
you will be able to filter a Netscape browser, for example, ( or any browser listed )
by using the Type, Name, Major Version or Minor Version attributes obtained
with Request.Browser, per the script supplied.
.NET 2.0 changes the detection process slightly, and the location
of individual browser detection files, so I won't discuss it here.
Good luck, and let us know how you do!
Juan T. Llibre
ASP.NET MVP
===========