Global virtualPath

来源:互联网 发布:安卓数据访问 编辑:程序博客网 时间:2024/04/30 11:13

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);
        }

原创粉丝点击