开发者

Removing default.aspx from the url in ASP.NET 2005

开发者 https://www.devze.com 2023-04-07 21:20 出处:网络
I have a app that is setup on IIS 6.0. We are having trouble with Search Engine optimization with the default.aspx page.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号