October 18, 2002 - Using the Global Server Object | WebReference

October 18, 2002 - Using the Global Server Object

Yehuda Shiran October 18, 2002
Using the Global Server Object
Tips: October 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

ASP.NET inherited the built-in objects from ASP. These objects are global in the sense that you don't need to construct them or pass them around; they are always there. There are five built-in objects: Request, Response, Server, Session, and Application.

The Server object includes one property and four methods. The property is ScriptTimeOut. It lets you control when the script processing should time out. The four methods are:

CreateObject: creates an instance of a server component. You must have this component installed on your server.
  • HtmlEncode: encodes a string in HTML.
  • MapPath: maps the current virtual directory to a given physical directory.
  • URLEncoding: URL-encodes a given string

    In IBuySpy, we convert the user name to HTML with Server.HtmlEncode and then save the HTML stream in a cookie, for personalizing the next "Welcome Back" message:

      Response.Cookies["IBuySpy_FullName"].Value = Server.HtmlEncode(Name.Text);