2010-07-22 2 views
1

У меня есть следующий вид структуры:RedirectToAction возвращает неправильный URL

 
Home 
    Index 

Security 
    Accounts 
      LogOn 

Следующий код в действии LogOn вызывает редирект http://localhost/Security/Home/Index вместо http://localhost/Home/Index

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

Вот мой маршрут регистрационный код для каждый:

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

безопасности

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

Любая помощь очень ценится.

ответ

2

Try перенаправление в пустую области строки:

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

Работает отлично! Благодарю. – sydneyos

Смежные вопросы