c# - Is possible to create strongly typed action link helper? -



c# - Is possible to create strongly typed action link helper? -

my goal pretty simple want create typed actionlink helper concrete controller in asp.net mvc. doesn't work; thought i'm on right way... can give me advice?

public static mvchtmlstring actionlinkfor<tcontroller>(this htmlhelper<tmodel> html, expression<func<tcontroller, actionresult>> action) { homecoming mvchtmlstring.empty; }

usage pretty simple (<li>@(html.actionlinkfor<hellocontroller>(a => a.index))</li>), i'm ending error message:

cs0428: cannot convert method grouping 'index' non-delegate type 'system.web.mvc.actionresult'. did intend invoke method?

instead of

<li>@(html.actionlinkfor<hellocontroller>(a => a.index))</li>

use

<li>@(html.actionlinkfor<hellocontroller>(a => a.index()))</li>

c# asp.net asp.net-mvc asp.net-mvc-4 lambda

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -