Export (0) Print
Expand All

ServerInfo Class

Displays information about the web server environment that hosts the current web page.

System.Object
  System.Web.Helpers.ServerInfo

Namespace:  System.Web.Helpers
Assembly:  System.Web.Helpers (in System.Web.Helpers.dll)

public static class ServerInfo

The ServerInfo type exposes the following members.

  NameDescription
Public methodStatic memberGetHtmlDisplays information about the web server environment.
Top

This class represents a helper, which is a component that simplifies web programming in ASP.NET Web Pages. You can use the ServerInfo class to troubleshoot issues with a website during development and testing. For example, the class can be used to display the virtual and physical paths of the pages in your application, which can help diagnose path-related issues in your code. The ServerInfo class includes many other types of information about the server environment that can be useful in solving programming or site issues, such as the identity of the logged-in user on the current web page, which version of Windows is running on the server, which HTTP method was used to request a web page (GET or POST), and so on.

To display information about the server, call the GetHtml method. The method displays information about the server in a series of HTML tables.

Security noteSecurity Note:

Because the ServerInfo class displays important information about your server that includes its operating system, the physical path of website files, and security information, you should remove any references to the ServerInfo class before you publish a web page to a production server.

The ServerInfo class provides the following kinds of information about the web server:

Information Type

Examples

Server configuration

Local time on the server, machine name, operating system version, user name, current directory, processor count.

ASP.NET server variables

Physical path of the web application, path of the current web page, logon user identity, server protocol, HTTP request method, web server name, URL of the page.

HTTP runtime information

Path of key directories like Bin and the .NET Framework CLR directory, ASP.NET installation directory, cache size, and machine configuration directory.

Environment variables

Web site name, path of key system folders such as the Program Files and Windows installation directory, user domain name, operating system, value of the path variable on your computer.

This example shows how to call the GetHtml method to display information about the server. Because the ServerInfo class is static, you do not have to create an instance of the class before you call the method.


<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
	<title>ServerInfo helper</title>
    </head>
    <body>
    @ServerInfo.GetHtml()
    </body>
</html>


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft