2

Previously I built an pluggable mvc4 app with a concept of areas in MVC4 as described in this article. I was facing problem in deploying this app and I solved it as described here.

Now I want to go one step further. I want to use nested areas i.e. area within area. Following is my project structure:

enter image description here

Here MainProj is the main project whereas other projects are areas. Now, in CRM area I want to add Area "ManageAppointments" (this is the nested area)

I am able to add this sub area but facing problem in routing. View engine never finds views present within ManageAppointments area.

I supposed this problem is because, the routing is aware of the areas within the main project, but it is not aware of that there is area within area. In simpler way, routing is aware of CRM area but it never searches for MangeAppointment area within CRM area i.e. it is not aware that there is again another area within CRM area.

Currently my area registration for CRM and MangeAppointment is as follows:

CRM:

public class CRMAreaRegistration : AreaRegistration
{
       public override string AreaName
       {
           get
           {
               return "CRM";
           }
       }

       public override void RegisterArea(AreaRegistrationContext context)
       {
           context.MapRoute(
               "CRM_default",
               "CRM/{controller}/{action}/{id}",
               new { action = "Index", id = UrlParameter.Optional },
               new string[] { "CRM.Controllers" }
           );
       }
 }

MangeAppointment:

public class MangeAppointmentAreaRegistration : AreaRegistration
{
          public override string AreaName
          {
              get
              {
                  return "MangeAppointment";
              }
          }

          public override void RegisterArea(AreaRegistrationContext context)
          {
              context.MapRoute(
                  "MangeAppointment_default",
                  "MangeAppointment/{controller}/{action}/{id}",
                  new { action = "Index", id = UrlParameter.Optional },
                  new string[] { "MangeAppointment.Controllers" }
              );
          }
 }

I think there is something wrong with MangeAppointment Area Registration. Thanks in advance.

1 Answer 1

2

simply change your MangeAppointment area registration as follows:

public override string AreaName
{
     get
     {
         return "CRM/Areas/MangeAppointment";
     }
}

If you simply return "MangeAppointment" it will search for ManageAppointment within main project i.e. it will search in location MainProj/Areas/MangeAppointment which is wrong location.

But when you return CRM/Areas/MangeAppointment it will search in the location MainProj/Areas/CRM/Areas/MangeAppointment.

Sign up to request clarification or add additional context in comments.

2 Comments

what should be the namespace for this class.? CRM or MainProj.? Please help.
And What will be Route Structure of controller actions inside the sub Area

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.