简体   繁体   中英

Code in view does not update after rebuild in ASP.NET MVC 4

Four domains are pointing to the same website, so to avoid having duplicate content I wrote this code at the beginning of _Layout.cshtml :

@if (!Request.Url.Host.Contains("example.com"))
{
    Response.Redirect("http://www.example.com" + Request.Url.AbsolutePath, true);
}

Then I realized that it also redirects on localhost, so I changed the code to:

@if (!Request.Url.Host.StartsWith("localhost") && !Request.Url.Host.Contains("example.com"))
{
    Response.Redirect("http://www.example.com" + Request.Url.AbsolutePath, true);
}

But on localhost it still redirects. to make sure I completely removed the code, tried Build , Rebuild , Clean then Rebuild , Remove dll files and no luck. The solution build is successful the solution is built and not using the old build.

Why the removed code still works?

Clearing browser's cache will solve the problem.

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