简体   繁体   English

在 ASP.NET MVC 4 中重建后视图中的代码不会更新

[英]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 :四个域都指向同一个网站,所以为了避免重复的内容,我在_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.为了确保我完全删除了代码,尝试了BuildRebuildClean 然后 RebuildRemove dll files但没有成功。 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.清除浏览器的缓存将解决问题。

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

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