Can i remove the “default.aspx” from the url?

情到浓时终转凉″ 提交于 2019-12-11 18:45:03

问题


When i try remove www from url:

www.jeans.com.vn

the result is: jeans.com.vn/default.aspx.

I don't want the /defaul.aspx too.

How can i remove it?

My code:

if (Request.Url.Host.StartsWith("www") && !Request.Url.IsLoopback)
{
    UriBuilder builder = new UriBuilder(Request.Url);
    builder.Host = Request.Url.Host.Replace("www.", "");
    Response.StatusCode = 301;
    Response.AddHeader("Location", builder.ToString());
    Response.End();
}

Thanks for any help!


回答1:


Just set Path to empty or "/":

builder.Path = "/";


来源:https://stackoverflow.com/questions/14699467/can-i-remove-the-default-aspx-from-the-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!