在 Global.asax 中添加 Application_BeginRequest 事件:
protected void Application_BeginRequest(object sender, EventArgs e)
{
    string pathAndQuery = Request.Url.PathAndQuery.ToLower();
    if (pathAndQuery.IndexOf(".html") > -1)
    {
        pathAndQuery = "~/" + pathAndQuery.Replace(".html"".aspx");
        HttpContext.Current.RewritePath(pathAndQuery);
    }
}
这样就可以在浏览器地址栏里用http://localhost/1234/xxx.html 来访问你的 http://localhost/1234/xxx.aspx页面了,浏览器地址栏显示的是http://localhost/1234/xxx.html (页面带参数也是可以的)。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-01
  • 2021-09-09
  • 2022-12-23
  • 2021-07-05
  • 2022-12-23
  • 2021-05-30
猜你喜欢
  • 2022-01-26
  • 2021-12-27
  • 2021-07-07
  • 2021-12-28
  • 2021-10-06
相关资源
相似解决方案