[英]Removing default.aspx from the url in ASP.NET 2005
我有一個在IIS 6.0上安裝的應用程序。 我們在使用default.aspx頁面進行搜索引擎優化時遇到了麻煩。 例如,當我輸入www.xxxxxx.com/default.aspx時,它應該重定向到www.xxxxxx.com。
誰能幫我解決這個問題?
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (HttpContext.Current.Request.RawUrl == "/default.aspx")
{
Response.StatusCode = 301;
Response.Status = "301 Moved Permanently";
Response.RedirectLocation = "/";
Response.End();
}
}
}
}
在“文檔”選項卡下的IIS中設置默認文檔。 進入“文檔”選項卡后,選中“啟用默認內容頁面”,然后將Default.aspx設置為列表中的第一項(或唯一項)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.