您好,欢迎来到dk游戏。
搜索
您的当前位置:首页把aspx页面伪装成静态html格式的实现代码

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

来源:dk游戏


在 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(页面带参数也是可以的)。

Copyright © 2019- dker.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务