Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 518
erikkallen Avatar asked Jul 15 '09 16:07

erikkallen


1 Answers

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

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

<%= Html.BuildUrlFromExpression<MyController>(x => x.MyMethod(a)) %>
like image 148
eu-ge-ne Avatar answered Sep 17 '22 13:09

eu-ge-ne