用global实现url重写,不配置iis

来源:互联网 发布:进出口数据统计 编辑:程序博客网 时间:2024/06/07 02:14

在global文件的添加如下代码:

实现  xxx.html----->>xxx.aspx

 

void Application_BeginRequest(object sender, EventArgs e)
    {
        if (Regex.IsMatch(Request.RawUrl.ToLower(), @".html") == true )
        {
            Context.RewritePath(Request.RawUrl.Replace(".html",".aspx"))

        }
    }

 

用上面的方法可以不用配置iis。

原创粉丝点击