Redirect to a controller in another Area

Asked

Viewed 1,196 times

2

I looked for a solution to this but could not, I’m trying to redirect session errors to login, my application is inside a folder called Areas and when he saw something redirect to him I redirect so :

  <li><a  href="@Url.Action("Enviadas", "Mensagem", new {PaginaAtual = 0, area = "Lojista" })"><i class="fa fa-envelope-o"></i>Enviadas</a></li>

But after I’m inside it I need to redirect to the login , which is in the Controllers folder outside the areas folder , (Controller and Areas are on the same level)

I’m trying to redirect like this :

if (loja == null)
{
    return RedirectToAction("Index", "Login", new {area = "~/Controllers" });
}

But this giving problem of route, if anyone knows answers I will be grateful.

EDIT : At the moment I try to redirect I am in the Dashboard Controller which is on ~/Areas/Lojista/Dashboard , and I need to redirect to the login, which is outside of Areas, which would be ~/Login In this case the login is in the normal controller folder of ASP.net and the rest is in ~/Areas/Lojista

1 answer

2


Just pass the empty area parameter. This will cause the Controller to be searched in the root area.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.