I'm my logout action method I'm trying to redirect to the loginurl as defined in the web.config.
I have tried
public ActionResult LogOff()
{
if(Request.IsAuthenticated)
FormsAuthentication.SignOut();
return RedirectToRoute(FormsAuthentication.LoginUrl);
}
However it returns an error
A route named '/Home/Index' could not be found in the route collection. Parameter name: name
The config setting is defined as follows
<authentication mode="Forms">
<forms loginUrl="/Home/Index" timeout="2880" />
</authentication>
Is there some other overload or method I should be using?
RedirectToRoute(string routeName) accept a RouteName not a path.
Use RedirectToAction
return RedirectToAction("Index", "Home");
Or Redirect
return Redirect(FormsAuthentication.LoginUrl);