【问题标题】:MVC RedirectPermanent to another domain ends in infinite loopMVC RedirectPermanent 到另一个域以无限循环结束
【发布时间】:2012-01-02 01:00:27
【问题描述】:

谁能看到我在这里做错了什么。我希望它会将我重定向到 http:\www.google.com,但我最终会陷入循环。

public ActionResult Index()
        {  
           var redirecturl = string.Format("http:\\www.google.com");
           return RedirectPermanent(redirecturl);
        }

如果你需要,这里是我的路线。

routes.MapRoute(
                "Default", // Route name
                "{*url}", // URL with parameters
                new { controller = "Redirect", action = "Index"} // Parameter defaults
            );

我最终得到了这样的网址 http://localhost:20000/google.com 和错误 Error 310 (net::ERR_TOO_MANY_REDIRECTS):

这是我创建的一个小示例,我想以一个小型 mvc 站点结束,它响应所有 url,创建一个日志条目,然后永久重定向到另一个域 (301)。

【问题讨论】:

  • 应该是http:// 而不是http:\\

标签: c# asp.net-mvc-3 http-status-code-301


【解决方案1】:

尝试重定向到 http://www.google.com 而不是 http:\www.google.com
如您所见,第一个是链接,而第二个不是

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-15
    • 1970-01-01
    • 2013-09-30
    • 2014-12-12
    • 2017-03-08
    • 2012-05-14
    相关资源
    最近更新 更多