简体   繁体   中英

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

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!

只需将Path设置为空或“/”:

builder.Path = "/";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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