asp.net-mvclambdaactionasp.net-mvc-futuresmagic-string

ASP.net MVC Action URLs with lambda expression


I'm sure I have seen this syntax

<%= Url.Action((MyController c) => c.MyMethod("a")) %>

or something like it as a way to generate action URLs in ASP.net MVCs without magic strings. However, I can't find that Action overload. I have ASP.NET MVC 1.0. Where is it?


Solution

  • You need ASP.NET MVC v1.0 Futures assembly:

    <%= Html.ActionLink<MyController>(x => x.MyMethod(a), "text") %>
    
    <%= Html.BuildUrlFromExpression<MyController>(x => x.MyMethod(a)) %>