Other Request Objects


This section covers several other Request objects that are very useful for development. The Browser collection enables you to find information about the user 's browser, and if necessary, adjust your content and rendering. And a number of other objects enable you to find information regarding paths and files.

The following code shows you how to find out a great deal of information about the client browser:

 <%    Dim bc As HttpBrowserCapabilities = Request.Browser  %>  Type: <%=bc.Type%><br>  Name: <%=bc.Browser%><br>  Version: <%=bc.Version%><br>  Major Version: <%=bc.MajorVersion%><br>  Minor Version: <%=bc.MinorVersion%><br>  Platform: <%=bc.Platform%><br>  Is Beta: <%=bc.Beta%><br>  Is Crawler: <%=bc.Crawler%><br>  Is AOL: <%=bc.AOL%><br>  Is Win16: <%=bc.Win16%><br>  Is Win32: <%=bc.Win32%><br>  Supports Frames: <%=bc.Frames%><br>  Supports Tables: <%=bc.Tables%><br>  Supports Cookies: <%=bc.Cookies%><br>  Supports VB Script: <%=bc.VBScript%><br>  Supports Java Script: <%=bc.JavaScript%><br>  Supports Java Applets: <%=bc.JavaApplets%><br>  Supports ActiveX Controls: <%=bc.ActiveXControls%><br>  CDF: <%=bc.CDF%><br> 

There's one important category of information that's missing, though, and that's the size of the client system window. This turns out to be very important when you want to adjust to a users screen resolution. The following JavaScript code displays the client's screen width and height in the HTML document.

 <SCRIPT LANGUAGE="JavaScript">  <!    document.writeln("The browser screen width is " + window.screen.width + "<br>")    document.writeln("The browser screen height is " + window.screen.height + "<br>")  //>  </SCRIPT> 


This code is part of the page that you can find at www.UsingASP.net, selecting Chapter Examples, Chapter 3, then Browser. You can see the rendered page in Figure 3.17.

Figure 3.17. The Browser object contains a lot of useful information.


Many times it's useful to know what the logical and physical path are. I've written applications that needed to save information to the current directory on the server's hard drive, and I needed to use a full path . You can find out the current directory with the Request.PhysicalPath() method.

The following code uses methods that I've found very useful to obtain file and path related information, and then output the results to the HTML document.

 <%    Dim strApplicationPath = Request.ApplicationPath()    Dim strFilePath = Request.FilePath()    Dim strPath = Request.Path()    Dim strPathInfo = Request.PathInfo()    Dim strPhysicalApplicationPath = Request.PhysicalApplicationPath()    Dim strPhysicalPath = Request.PhysicalPath()    Dim strURL = Request.URL()    Dim strURLReferrer = Request.URLReferrer()    Dim strUserAgent = Request.UserAgent()    Dim strUserHostAddress = Request.UserHostAddress()    Dim strUserHostName = Request.UserHostName()  %>  ApplicationPath: <%=strApplicationPath%><br>  FilePath: <%=strFilePath%><br>  Path: <%=strPath%><br>  PathInfo: <%=strPathInfo%><br>  PhysicalApplicationPath: <%=strPhysicalApplicationPath%><br>  PhysicalPath: <%=strPhysicalPath%><br>  URL: <%=strURL%><br>  URLReferrer: <%=strURLReferrer%><br>  UserAgent: <%=strUserAgent%><br>  UserHostAddress: <%=strUserHostAddress%><br>  UserHostName: <%=strUserHostName%><br> 


This code is part of the page that you can find at www.UsingASP.net, selecting Chapter Examples, Chapter 3, then Miscellaneous. You can see the rendered page in Figure 3.18.

Figure 3.18. Shown here are some very useful objects that provide valuable information.



Special Edition Using ASP. NET
Special Edition Using ASP.Net
ISBN: 0789725606
EAN: 2147483647
Year: 2002
Pages: 233

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net