把a(bǔ)spx頁面?zhèn)窝b成靜態(tài)html格式的實(shí)現(xiàn)代碼
更新時(shí)間:2011年10月19日 23:01:41 作者:
把a(bǔ)spx頁面?zhèn)窝b成靜態(tài)html格式的實(shí)現(xiàn)代碼,主要是利于搜索引擎的收錄。
在 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(頁面帶參數(shù)也是可以的)。
復(fù)制代碼 代碼如下:
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(頁面帶參數(shù)也是可以的)。
相關(guān)文章
解析.netcore項(xiàng)目中IStartupFilter使用教程
netcore項(xiàng)目中有些服務(wù)是在通過中間件來通信的,比如orleans組件,今天通過實(shí)例代碼給大家介紹下netcore項(xiàng)目中IStartupFilter使用教程,感興趣的朋友一起看看吧2021-11-11ASP.NET技巧:數(shù)據(jù)島出到Excel最為簡易的方法
ASP.NET技巧:數(shù)據(jù)島出到Excel最為簡易的方法...2006-09-09如何給ASP.NET Core Web發(fā)布包做減法詳解
在ASP.Net中可以使用打包與壓縮這兩種技術(shù)來提高Web應(yīng)用程序頁面加載的性能。下面這篇文章主要給大家介紹了關(guān)于如何給ASP.NET Core Web發(fā)布包做減法的相關(guān)資料,需要的朋友可以參考借鑒,下面來一起看看吧2018-06-06asp.net用三層實(shí)現(xiàn)多條件檢索示例
三層將項(xiàng)目分為界面層,業(yè)務(wù)邏輯層和數(shù)據(jù)訪問層,下面為大家介紹下asp.net如何用三層實(shí)現(xiàn)多條件檢索,感興趣的朋友可以參考下2014-07-07