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:
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.