Question

Im having a problem getting donutcaching to work on an area i MVC3.

It seems that the "area"-attribute doesnt get passed along in the routeValueDictionary to the HtmlHelper Action-method in MvcDonutCaching.

I have a childaction that gets called like this: @Html.Action("Header", "Menu", true), and that works fine for all controllers that are not ind an area - but as soon it lies within an area, it cannot de found:

"The controller for path '/Indberetning/Administration/Index' was not found or does not implement IController."

I found out that the area doesnt get passed along to the exensionmethod that renders the action. Anyone has a solution for this? :)

AreaRegistration: public class IndberetningAreaRegistration : AreaRegistration { public override string AreaName { get { return "Indberetning"; } }

    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
          "Indberetning_DiscoHovedgruppe",
          "Indberetning/Disco/Hovedgrupper/{hovedgruppe}",
          new { controller = "Disco", action = "Hovedgrupper", hovedgruppe = UrlParameter.Optional }
      );
        context.MapRoute(
                      "Indberetning_FejlrapportIlOptaelling",
                      "Indberetning/Fejlrapport/IlOptaelling/il{iltype}/{fejltype}/side-{page}",
                      new { controller = "Fejlrapport", action = "IlOptaelling", page = 1 }
                  );


        context.MapRoute(
          "Indberetning_FejlrapportIpOptaelling",
          "Indberetning/Fejlrapport/IpOptaelling/ip{iptype}/{fejltype}/side-{page}",
          new { controller = "Fejlrapport", action = "IpOptaelling", page = 1 }
      );

        context.MapRoute(
         "Indberetning_Fejlrapport",
         "Indberetning/Fejlrapport/{action}/",
         new { controller = "Fejlrapport", action = "Fejlrapport" }
     );

        context.MapRoute(
          "Indberetning_VirksomhedUgyldigArbejdssted",
          "Indberetning/Virksomhed/UgyldigArbejdssted/{pnummer}/side-{page}/{tmetode}",
          new { controller = "Virksomhed", action = "UgyldigArbejdssted", page = 1, tmetode = UrlParameter.Optional }
      );

        context.MapRoute(
         "Indberetning_VirksomhedArbejdssted",
         "Indberetning/Virksomhed/Arbejdssted/{denr}/side-{page}/{tmetode}",
         new { controller = "Virksomhed", action = "Arbejdssted", page = 1, tmetode = UrlParameter.Optional }
     );

        context.MapRoute(
        "Indberetning_VirksomhedArbejdssteder",
        "Indberetning/Virksomhed/Arbejdssteder/side-{page}",
        new { controller = "Virksomhed", action = "Arbejdssteder", page = UrlParameter.Optional }
    );

        context.MapRoute(
           "Indberetning_DiscoDetaljer",
           "Indberetning/Disco/Detaljer/Hoveddiscogruppe-{id}/{jobStatus}",
           new { controller = "Disco", action = "Detaljer", jobStatus = UrlParameter.Optional }
       );
        context.MapRoute(
            "Indberetning_default",
            "Indberetning/{controller}/{action}/{id}",
            new { controller = "Forside", action = "Forside", id = UrlParameter.Optional }
        );
    }
}

The code runs fine without the outputcache implementation

Was it helpful?

Solution

You need to use this overload of the Html.Action method:

public static MvcHtmlString Action(this HtmlHelper htmlHelper,
                                        string actionName,
                                        string controllerName,
                                        object routeValues,
                                        bool excludeFromParentCache)

And in you your case:

@Html.Action("Header", "Menu", new { Area = "AreaName" }, true)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top