public static class Global
{
public static string TempPath { get; set; }
public static string RootPath { get; set; }
public static string FilePath { get; set; }
public static string ConfigPath { get; set; }
public static string VirtualPath { get; set; }
public static string UrlParser(string url)
{
return Regex.Replace(url, "^~/", VirtualPath + "/");
}
}
protected void Page_Load(object sender, EventArgs e)
{
Global.VirtualPath = Request.ApplicationPath.TrimEnd('/');
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath, false);
}
本文介绍了一个静态全局类Global,其中包含多个静态属性用于保存路径信息,如临时文件夹路径、根目录路径等,并实现了一个URL解析方法,该方法将URL中的'~/...'前缀替换为虚拟路径对应的绝对路径。
99

被折叠的 条评论
为什么被折叠?



