最简单的方法是将控制器名称和操作名称作为模型上的字符串。然后你可以使用actionlink的非强类型重载。像这样的东西:
<%=Html.ActionLink(Model.Action, Model.Controller, new { param1 = 1, param2 = 2 })%>
并像这样使用它:
<%Html.RenderPartial("PartialName", new PartialModel{Controller = "Person", Action = "Publications"})%>
如果你想使用强类型版本,你可以这样做:
//Model for your partial view
public class PartialModel<TController> where TController : Controller
{
public Func<int, int, Expression<Action<TController>>> GetLinkAction { get; set; }
}
//Render the action link in your partial
<%=Html.ActionLink(Model.GetLinkAction(1, 2))%>
//Render the partialview in any page
<%Html.RenderPartial("PartialName", new PartialModel<PersonController> { GetLinkAction = (param1, param2) => x => x.Publications(param1, param2) })%>
You will of course have to adjust this for the parameters that you have. The nice thing about the strongly typed way is that the methods doesn't have to have the exact same signature and parameter names.