把aspx页面伪装成静态html格式的实现代码_asp.net教程-查字典教程网
把aspx页面伪装成静态html格式的实现代码
把aspx页面伪装成静态html格式的实现代码
发布时间:2016-12-29 来源:查字典编辑
摘要:在Global.asax中添加Application_BeginRequest事件:复制代码代码如下:protectedvoidApplic...

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

}

}

这样就可以用xxx.html 来访问你的 xxx.aspx页面了,浏览器地址栏显示的是xxx.html(页面带参数也是可以的)。

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新asp.net教程学习
    热门asp.net教程学习
    编程开发子分类