【发布时间】:2017-02-15 07:06:36
【问题描述】:
四个域指向同一个网站,所以为了避免重复内容,我在_Layout.cshtml开头写了这段代码:
@if (!Request.Url.Host.Contains("example.com"))
{
Response.Redirect("http://www.example.com" + Request.Url.AbsolutePath, true);
}
然后我意识到它也在localhost上重定向,所以我将代码更改为:
@if (!Request.Url.Host.StartsWith("localhost") && !Request.Url.Host.Contains("example.com"))
{
Response.Redirect("http://www.example.com" + Request.Url.AbsolutePath, true);
}
但在本地主机上它仍然重定向。确保我完全删除了代码, 尝试了 Build、Rebuild、Clean then Rebuild、Remove dll files,但没有成功。解决方案构建成功,解决方案已构建,而不是使用旧版本。
为什么删除的代码仍然有效?
【问题讨论】:
-
您是否尝试过清除浏览器的缓存?
-
@Berkay 缓存了什么?
-
隐身模式的行为也一样吗?
-
@IoanaStoian 实际上在隐身模式下工作。但这让我更加困惑。为什么(以及如何)可以在浏览器中缓存服务器端代码?
-
视图呈现为html,因此浏览器可能再次显示缓存的html
标签: c# asp.net asp.net-mvc asp.net-mvc-4