当前位置:编程学习 > C#/ASP.NET >>

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

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

上一个:jquery repeater 模仿 Google 展开页面预览子视图
下一个:得到真实外网IP、IP所在国家、省份、地区(小偷程序)

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,