usermappath.cs

来自「Professional ASP.NET source code」· CS 代码 · 共 33 行

CS
33
字号
using System;
using System.Web;

public class UserMapPath : IHttpModule {
  public String ModuleName {
    get {
      return "UserMapPath";
    }
  }

  public void Init(HttpApplication app) {
    app.BeginRequest += new EventHandler(this.App_BeginRequest);
  }

  public void App_BeginRequest(Object sender, EventArgs e) {
    HttpApplication application = (HttpApplication) sender;
    HttpContext context = application.Context;
    HttpRequest Request = context.Request;

    String path = Request.Path;
    int index = path.IndexOf("~");
    
    if (index > 0) {
      String newPath = path.Substring(0, (index - 1));
      String name = path.Substring(index);
context.Response.Write(newPath + " : " + name);
      
    }
  }

  public void Dispose() {
  }
}

⌨️ 快捷键说明

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