asp.net mvc - Html.ActionLink Run My Action for several times in MVC C# -


in view:

<%=html.actionlink(dr["productlinklabel"].tostring(), "downloadfile", "home", new { linkid = dr["productlinksn"]},null)%> 

in controller:

    [nocache]     [httpget]     public actionresult downloadfile(int linkid)     {         datamodeldatacontext db =new datamodeldatacontext();         productlink_getforeditresult link = db.productlink_getforedit(linkid).firstordefault();         string linkurl = link.productlinkurl;         db.productlink_downloadupdate(linkid);         string filename = linkurl.split('/').last();         return file(server.mappath(linkurl), system.net.mime.mediatypenames.application.octet, filename);     } 

downloadfile method calls html.actionlink several times. must run @ once, call method random times

use

<%=html.actionlink("linkname","actionname",new {id=1,name"test"})%> 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -