title: MVC - Route not registering
body: <p>This is a problem which is quite common here on SO, but so far not one of the found solutions did solve the problem for me. Examples of followed links: </p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/25450549/getting-error-404-not-found-with-asp-net-mvc-area-routing">Getting error 404 not found with ASP.NET MVC Area routing</a></li>
  <li><a href="https://forums.asp.net/t/1635265.aspx?MVC+3+New+Area+404+error+Resource+not+found+have+tried+route+debugger" rel="nofollow noreferrer">https://forums.asp.net/t/1635265.aspx?MVC+3+New+Area+404+error+Resource+not+found+have+tried+route+debugger</a></li>
  <li><a href="https://stackoverflow.com/questions/22022386/mvc-html-actionlink-not-rendering-can-you-spot-what-im-doing-wrong">MVC Html.ActionLink not rendering. Can you spot what I&#39;m doing wrong?</a></li>
  </ul>
  
  <p>However my problem is the following: for the revenues area the complete routing and everything is working. The URL is also correct as <code>/Revenues/Revenue/Unconfirmed</code>
  For the Campaigns area the actionlink remains always as an empty href, so it does not get rendered and thus creates on click an URL like <code>current page/#</code>. However when the Revenues.dll is not in my application then it renders the actionlink (for both areas) as <code>/Controller/Action?area=AreaName</code></p>
  
  <p><strong>Project layout (MVC)</strong></p>
  
  <p>`</p>
  
  <pre><code>Solution
     | Main MVC APP (does only authentication)
         | Models
         | Controllers
         | Views
         | Areas (this are hidden MVC projects)
         | global.asax 
         | ...
     | Modules (just an folder with all the projects of each area in it)
         | Campaigns 
            | Models
            | Controllers
            | Views
         | Revenues
            | Models
            | Controllers
            | Views`
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/HPQQc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HPQQc.png" alt="enter image description here"></a></p>
  
  <ul>
  <li>Each area is a project on its own and is linked into the main solution.</li>
  <li>Each area will be build as an .dll and then linked into the Main MVC app</li>
  <li>All models are in the namespace --> CustomerPortal.Models, for the rest has each area its own namespace.</li>
  <li>The views inside the areas are configured as <code>Embedded resource</code> because else the localizations with resource files did not want to work correctly. The Browse to URL conforms to the following path <code>~/Area/Controller/Action</code></li>
  </ul>
  
  <p><strong>Code samples</strong></p>
  
  <p><em>Main MVC APP</em></p>
  
  <p>RouteConfig.cs</p>
  
  <pre><code>public static void RegisterRoutes(RouteCollection routes)
      {
          routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
          AreaRegistration.RegisterAllAreas();
          routes.MapRoute(
              name: "Default",
              url: "{controller}/{action}/{id}",
              defaults: new { controller = "Portal", action = "Index", id = UrlParameter.Optional },
              namespaces: new string[] { "CustomerPortal.Controllers" }
          ).DataTokens["UseNamespaceFallback"] = false;
      }
  </code></pre>
  
  <p>_Menu.cshtml</p>
  
  <pre><code>&lt;li class="treeview"&gt;
          &lt;a href="#"&gt;
              &lt;i class="fa fa-users"&gt;&lt;/i&gt; &lt;span&gt;Campaigns&lt;/span&gt;
              &lt;span class="pull-right-container"&gt;
                  &lt;i class="fa fa-angle-left pull-right"&gt;&lt;/i&gt;
              &lt;/span&gt;
          &lt;/a&gt;
          &lt;ul class="treeview-menu"&gt;
              &lt;li&gt;@Html.ActionLink("Reactions", "CampaignResponses", "Campaign", new { area = "Campaigns" }, new { })&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li class="treeview"&gt;
          &lt;a href="#"&gt;
              &lt;i class="fa fa-bar-chart"&gt;&lt;/i&gt; &lt;span&gt;Revenues&lt;/span&gt;
              &lt;span class="pull-right-container"&gt;
                  &lt;i class="fa fa-angle-left pull-right"&gt;&lt;/i&gt;
              &lt;/span&gt;
          &lt;/a&gt;
          &lt;ul class="treeview-menu"&gt;
              &lt;li&gt;@Html.ActionLink(Title.Unconfirmed, "Unconfirmed", "Revenue", new { area = "Revenues" }, new { })&lt;/li&gt;
              &lt;li&gt;@Html.ActionLink(Title.RevenueConfirmed, "Confirmed", "Revenue", new { area = "Revenues" }, new { })&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/li&gt;
  </code></pre>
  
  <p><em>Revenues</em></p>
  
  <p>RevenuesAreaRegistration.cs</p>
  
  <pre><code>namespace Revenues {
  public class RevenuesAreaRegistration : AreaRegistration
  {
      public override string AreaName
      {
          get
          {
              return "Revenues";
          }
      }
      public override void RegisterArea(AreaRegistrationContext context)
      {
          context.MapRoute(
              "Revenues_default",
              "Revenues/{controller}/{action}/{id}",
              new { controller = "Revenue", action = "Index", id = UrlParameter.Optional },
              new string[] { "Revenues.Controllers" }
          );
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>RevenueController.cs </p>
  
  <pre><code>namespace Revenues.Controllers
  {
      [Authorize]
      [RouteArea("Revenues")]
      public class RevenueController : Controller
      {
         public ActionResult Unconfirmed() {
         ...
  </code></pre>
  
  <p><em>Campaigns</em></p>
  
  <p>CampaignsAreaRegistration.cs</p>
  
  <pre><code>namespace Campaigns
  {
      public class CampaignsAreaRegistration : AreaRegistration
      {
          public override string AreaName
          {
              get
              {
                  return "Campaigns";
              }
          }
  
          public override void RegisterArea(AreaRegistrationContext context)
          {
              context.MapRoute(
                  "Campaigns_default",
                  "Campaigns/{controller}/{action}/{id}",
                  new { controller = "Campaign", action = "CampaignResponses", id = UrlParameter.Optional },
                  new string[] { "Campaigns.Controllers" }
              );
          }
      }
  }
  </code></pre>
  
  <p>CampaignController.cs</p>
  
  <pre><code>namespace Campaigns.Controllers
  {
      [Authorize]
      [RouteArea("Campaigns")]
      public class CampaignController : Controller
      {
          public ActionResult CampaignResponses()
          {
              SetData();
              return View();
          }
  </code></pre>
  
  <p>I hope someone sees what I look over on. Have been doing trail and failure for almost a day now and still no solution found for it...</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>After having done a deeper search with the following code I have found out that it only registers the Main MVC App and Revenues routes. The Campaigns is not registered at all. But so far no clue yet why this happens.</p>
  
  <pre><code>public override void Init()
          {
              base.Init();
              this.AcquireRequestState += ShowRouteValues;
          }
  
          protected void ShowRouteValues(object sender, EventArgs e)
          {
              var context = HttpContext.Current;
              if (context == null)
              {
                  return;
              }
              var routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(context));
          }
  </code></pre>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>It seems that the .dll is not being registered in the Main MVC App.
  I forgot to say that this all is running on azure as an App Service.</p>
  
  <p>But I have registered the Route now directly in the RouteConfig.cs from the MainApp, this registers the complete route in the actionlink however, it still does not find the Controller action then. So it has to be a problem with the .dll.
  This has been added as a reference to the main project and it is also available in the App Service</p>