Wednesday 15 May 2013

Area ASP.NET MVC 4 strangely not working -


I have a strange problem in working with areas in ASP.NET MVC 4.

  root --- region --- admin ___ home controller ___ agent controller --- admin_gn_ ___ home controller ___ agent controller   

the admin area works perfectly Now, when I went to Agnies, it works when I redirect the Home Controller and when I am an Agent Controller or any other controller, this is my rule for both areas:

  Public Class Administration Array Registration: Area Registration {public override string Ariaanam {get {return "AdminAgence"; }} Public override blank register arraya (area registration contact reference) {reference.MapRoute ("AdminAgence_default", "AdminAgence / {controller} / {action} / {id}", new {controller = "home", action = "index" , ID = UrlParameter.Optional}); For the Admin Area (which works perfectly)  
  Public Class AdministratorArera Registration: Regional Registration {Get Public Override String Area Name {Return {Return "Admin"; }} Override the public override blank register arraya (AriaRejestation contact reference) {reference.MapRoute ("Admin_default", "Admin / {controller} / {action} / {id}", new {controller = "home", action = "index" , Id = UrlParameter.Optional}); }}   

and global .asax.cs

  public class MvcApplication: System.Web.HttpApplication {secure void Application_Start () {AreaRegistration.RegisterAllAreas () ; WebApiConfig.Register (GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters (GlobalFilters.Filters); RouteConfig.RegisterRoutes (RouteTable.Routes); BundleConfig.RegisterBundles (BundleTable.Bundles); AuthConfig.RegisterAuth (); }}   

I made the AdminAgence area the same as an administrator and nothing for AdminAgence ...

I also have the role to work with roles To define every field, and roles field administrator, AdminAgence and Membre

You should not add anything to the most The good thing is that you have to remove all routing from your existing project, which will refer to the name of your new area , And then let the framework handle all routing for you.

No comments:

Post a Comment