网络编程 
首页 > 网络编程 > 浏览文章

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

(编辑:jimmy 日期: 2025/12/26 浏览:3 次 )
在 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平台下的图片在线裁剪功能的实现代码(源码打包)
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 网站地图 SiteMap