Asp.net mvc 不要缓存Mvc3和区域
我在让donutcaching在MVC3区域工作时遇到问题 似乎routeValueDictionary中的“area”属性没有传递给MVCDonutCache中的HtmlHelper操作方法 我有一个像这样被调用的childaction:Asp.net mvc 不要缓存Mvc3和区域,asp.net-mvc,asp.net-mvc-3,caching,asp.net-mvc-routing,outputcache,Asp.net Mvc,Asp.net Mvc 3,Caching,Asp.net Mvc Routing,Outputcache,我在让donutcaching在MVC3区域工作时遇到问题 似乎routeValueDictionary中的“area”属性没有传递给MVCDonutCache中的HtmlHelper操作方法 我有一个像这样被调用的childaction:@Html.Action(“Header”,“Menu”,true),它适用于所有不在某个区域内的控制器,但一旦它位于某个区域内,就无法找到它: “路径'/Indberetning/Administration/Index'的控制器未找到或未实现IContro
@Html.Action(“Header”,“Menu”,true)
,它适用于所有不在某个区域内的控制器,但一旦它位于某个区域内,就无法找到它:
“路径'/Indberetning/Administration/Index'的控制器未找到或未实现IController。”
我发现该区域没有传递给呈现动作的exensionmethod。有人对此有解决方案吗?:)
地区注册:
公共类IndberetningarearRegistration:区域注册
{
公共重写字符串区域名
{
收到
{
返回“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 }
);
}
}
如果没有outputcache实现,代码运行正常您需要使用此超负荷的
Html。操作
方法:
public static MvcHtmlString Action(this HtmlHelper htmlHelper,
string actionName,
string controllerName,
object routeValues,
bool excludeFromParentCache)
就你而言:
@Html.Action("Header", "Menu", new { Area = "AreaName" }, true)
感谢您的快速回复:)不幸的是,它不起作用。我现在可以看到区域被传递得很好,有趣的是,当代码执行时(在我发生异常之后),routevaluedictionary被清空。它现在有0个条目的长度。非常奇怪(显示区域被传递的图像)(图1单步,现在routvaluedictionary为空)向问题添加更多代码,显示请求的Controller.Action代码以及区域注册。如果直接调用请求的操作(不使用
@Html.Action
),会怎么样?我已更新了问题:)要包含的控制器/操作很简单:public ActionResult Index(){return View(new AdministrationIndexViewModel());}