global.asax

来自「Professional ASP.NET source code」· ASAX 代码 · 共 32 行

ASAX
32
字号
<%@ Import Namespace="System.Xml" %>

<Script Language="C#" runat="server">

  public void Application_OnAcquireRequestState(Object sender, EventArgs e) {
    XmlDocument dom = new XmlDocument();
    string customerType;

    // Grab the customerType from the QueryString
    customerType = Request.QueryString["customerType"];

    // Check for values
    //if (customerType == null)
     // customerType = "Bronze";

    // Load the appropriate XML file
    switch (customerType)
    {
      case "Gold":
        dom.Load(Server.MapPath("Gold.xml"));
        break;
      case "Silver":
        dom.Load(Server.MapPath("Silver.xml"));
        break;
      default:
        dom.Load(Server.MapPath("Bronze.xml"));
        break;
    }

    Session["WelcomeMsg"] = dom.SelectSingleNode("/customer/welcome").InnerText;
  }
  </Script>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?