我们有一个用 ASP.NET 编写的网站。当您打开以下页面时:
您可以在末尾看到斜线“/”。我们需要删除它才能拥有:
我已经尝试了一些事情来使它工作,但它没有帮助。例如,当我在 Global.asax.cs 文件中添加以下代码时:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if (HttpContext.Current.Request.Url.ToString().Contains("http://concert.local/elki/"))
{
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", Request.Url.ToString().ToLower().Replace("http://concert.local/elki/", "http://concert.local/elki"));
}
}
出现以下错误:
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept cookies.
还有以下代码:
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentHead">
<link rel="canonical" href="http://concert.local/elki" />
</asp:Content>
这将规范的东西放在页眉中。
如何获得以下网址:
?