c# - UrlHelper.Action not rendering Controller or Action in link -


i'm trying use custom image helper similar this asp mvc post. below code use, accepts string input parameter controller , action. helper users urlhelper.action() method process strings and, supposedly, generate relative url.

however, can see screen shot below, item in url rendered route data. no controller or action. value of string url equal simply
/?agentid=1917513249, despite find , agent being present values controllername , actionname strings.

    public static mvchtmlstring imagelink(this htmlhelper htmlhelper, string imgsrc, string alt, string actionname,                                           string controllername, object routevalues, object imgattributes, object htmlattributes)     {         urlhelper urlhelper = ((controller) htmlhelper.viewcontext.controller).url;         var imgtag = new tagbuilder("img");         imgtag.mergeattribute("src", imgsrc);         imgtag.mergeattributes(htmlhelper.anonymousobjecttohtmlattributes(imgattributes), true);          string url = urlhelper.action(actionname, controllername, routevalues);         var imglink = new tagbuilder("a");         imglink.mergeattribute("href", url);         imglink.innerhtml = imgtag.tostring();         imglink.mergeattributes(htmlhelper.anonymousobjecttohtmlattributes(htmlattributes), true);          return mvchtmlstring.create(imglink.tostring());     } 

edit

below razor use call helper

@foreach (var in item.agentids) {     @html.imagelink(url.content("~/content/images/concode.png"), null, "find", "agent", new {agentid=a.agentid}, new { title = "get con code" }, null)     <br/>                      } 

enter image description here


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -