【发布时间】: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