简体   繁体   English

从ASP.NET 2005中的URL中删除default.aspx

[英]Removing default.aspx from the url in ASP.NET 2005

I have a app that is setup on IIS 6.0. 我有一个在IIS 6.0上安装的应用程序。 We are having trouble with Search Engine optimization with the default.aspx page. 我们在使用default.aspx页面进行搜索引擎优化时遇到了麻烦。 For Example when I type www.xxxxxx.com/default.aspx it should redirect to www.xxxxxx.com. 例如,当我输入www.xxxxxx.com/default.aspx时,它应该重定向到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. 在“文档”选项卡下的IIS中设置默认文档。 Once in the Documents tab, check "Enable default content page" and set Default.aspx as the first item (or only) in the list. 进入“文档”选项卡后,选中“启用默认内容页面”,然后将Default.aspx设置为列表中的第一项(或唯一项)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM