把aspx页面伪装成静态html格式的实现代码
更新时间:2011年10月19日 23:01:41 作者:
把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(页面带参数也是可以的)。
复制代码 代码如下:
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文件上传功能(单文件,多文件,自定义生成缩略图,水印)
上传功能,是大家经常用到了,可能每一个项目都可以会用到。网上到处都有上传功能的代码。比我写的好的有很多。我这里也仅是分享我的代码。2011-09-09
.Net中关于stirng转System.Type的一种实现思路详解
这篇文章主要给大家介绍了.Net中关于stirng转System.Type的一种实现思路的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2018-05-05


最新评论