I solved this problem by doing the following.
In my Global.asax.cs I have
public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); } public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" }); } protected void Application_Start() {
In my PublicAreaRegistration.cs (Public Area) I have
public class PublicAreaRegistration : AreaRegistration { public override string AreaName { get { return "Public"; } } public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute("Root", "", new { controller = "Home", action = "Index" }); context.MapRoute( "Public_default", "Public/{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional } , new[] { "<Project Namespace here>.Areas.Public.Controllers" } ); } }
In my AuthAreaRegistration.cs (Area for Restricted access) I have
public class AuthAreaRegistration : AreaRegistration { public override string AreaName { get { return "Auth"; } } public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "Auth_default", "Auth/{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } }
And finally, my links on my * .cshtml pages will look like
1) @ Html.ActionLink ("Logout", "LogOff", new {area = "Public", controller = "Home"})
or
2) @ Html.ActionLink ("Admin Area", "Index", new {area = "Auth", controller = "Home"})
Hope this saves time on research! By the way, I'm talking about MVC3 here.
Kwex.