Strongly typed actionlink with asp.net mvc beta?

久未见 提交于 2020-01-03 13:36:07

问题


I used to be able to do the following in Preview 3

<%=Html.BuildUrlFromExpression<AController>(c => c.AnAction(par1, par2)%>

How am I supposed to create urls in a strongly typed way with the MVC Beta? The only thing so far I have found is

<%= Html.ActionLink("aName", "ActionName", "ControllerName")%>

This is not strongly typed off course.


回答1:


You need the ASP.NET MVC Beta Futures, which is a separate download

ASP.NET MVC Beta Futures

then your original code will work as before.

See this post for getting it working: SO post on missing extensions




回答2:


The Microsoft.Web.Mvc assembly provides extension methods to the HtmlHelper which allow something like

<%= Html.ActionLink<SomeController>(c => c.Index()) %>


来源:https://stackoverflow.com/questions/218256/strongly-typed-actionlink-with-asp-net-mvc-beta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!