如何在ASp.NET MVC 3中缓存PartialViews的输出?我知道我可以用[OutputCache]属性修饰动作,但我只想将@OutputCache包含在PartialView中,如下所示:
@OutputCacheAttribute
@model MvcApplication1.Models.someViewmodel
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@Html.Partial("_MyPartialView")
Run Code Online (Sandbox Code Playgroud) 在我的路线中我有这样的事情:
controller/action/{id}
Run Code Online (Sandbox Code Playgroud)
据我所知,这意味着它将使用参数id调用任何操作,如下所示:
public ActionResult Detail(string id)
{
}
Run Code Online (Sandbox Code Playgroud)
如果不在global.asax文件中注册特定路由,我需要做什么才能完成以下工作:
public ActionResult Detail(string customerId)
{
}
Run Code Online (Sandbox Code Playgroud)