首页 > Web开发 > 详细

把aspx页面伪装成静态html格式的实现代码

时间:2016-01-20 21:00:00      阅读:146      评论:0      收藏:0      [点我收藏+]
在 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(页面带参数也是可以的)。

把aspx页面伪装成静态html格式的实现代码

原文:http://www.jb51.net/article/28591.htm

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!