Removing default.aspx from the url in ASP.NET 2005
I have a app that is setup on IIS 6.0. We are having trouble with Search Engine optimization with the default.aspx page. For Example when I type www.x开发者_如何学Goxxxxx.com/default.aspx it should redirect to www.xxxxxx.com.
Can anyone please help me with this problem?
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();
}
}
}
}
Set the default document in IIS under the Documents tab. Once in the Documents tab, check "Enable default content page" and set Default.aspx as the first item (or only) in the list.
精彩评论