I would like to change the place my website redirects user when they are not logged in.
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="30" />
</authentication>
It uses the AccountController in the default Controllers folder, the action method LogOn and the View attached to this.
I have another AccountController placed in this folder: Areas/SmallSurvey/Controllers/Account
the name of the action method is the same. I can’t figure out the syntax to use.
I have tried different names but none of them work. How do i change it?
Global.asax.cs:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new[] { "MvcApplication3.Controllers" }
);
}
This is how SmallSurveyAreaRegistration.cs looks like:
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"SmallSurvey_default",
"SmallSurvey/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
context.MapRoute("Login", "SmallSurvey/Account/LogOn",
new { controller = "Account", action = "LogOn" },
new[] { "MvcApplication3.Areas.SmallSurvey.Controllers" });
}
When trying to access “SmallSurvey/Account/LogOn” i get the following error:
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /SmallSurvey/Account/LogOn
1 Answer