开发者

RedirectToAction returns wrong url

I have the following View structure:

Home
    Index

Security 
    Accounts
          LogOn

The following code in the LogOn action causes a redirect to http://localhost/Security/Home/Index instead of http://localhost/Home/Index

return RedirectToAction("Index", "Home");

Here is my Route registration code for each:

Home

   routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new {controller = "Home", action = "Index", id = UrlParameter.Optional} // Parameter defaults
                );

Security

public override void RegisterArea(System.Web.Mvc.AreaRegistrationContext context) {
            context.MapRoute(
                    "Security_default",
                    "Security/{controller}/{action}",
                    new { action = "LogOn" }
                开发者_JAVA百科);
        }

Any help greatly appreciated.


Try redirecting to the empty string area:

return RedirectToAction("Index", "Home", new { area = "" });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜