Generic Action Link in MVC 3 / Razor

2020-06-16 09:03发布

问题:

Just started a new MVC 3 project and I can't get the strongly-type generic action link and url helpers I am used to in MVC 2 futures.

Which nuget packages and namespaces do I need to get hold off?

Example

Html.ActionLink<HomeController>(c => c.Index(), "Home")

ANSWER:

Just needed to reference Microsoft.Web.Mvc via NuGet MvcContrib - and make the namespace available in the views.

回答1:

Which nuget packages and namespaces do I need to get hold off?

  • Official NuGet Mvc3Futures package is here
  • Namespace to declare is Microsoft.Web.Mvc


回答2:

Grab the T4MVC package in NuGet.



回答3:

Just need to reference Microsoft.Web.Mvc