Home Ask Login Register

Developers Planet

Your answer is one click away!

Hossein Shahabi February 2016

Html.ActioLink Run My Action for serveral times in MVC C#

in view:

<%=Html.ActionLink(dr["ProductLinkLabel"].ToString(), "downloadFile", "Home", new { LinkID = dr["ProductLinkSN"]},null)%>

in controller:

    public ActionResult downloadFile(int LinkID)
        DataModelDataContext db =new DataModelDataContext();
        ProductLink_GetForeditResult link = db.ProductLink_GetForedit(LinkID).FirstOrDefault();
        string LinkUrl = link.ProductLinkUrl;
        string fileName = LinkUrl.Split('/').Last();
        return File(Server.MapPath(LinkUrl), System.Net.Mime.MediaTypeNames.Application.Octet, fileName);

downloadFile Method calls by Html.ActionLink for several times. It must run at once, but call method random times


Hafiz Asad February 2016

Use this

<%=Html.ActionLink("LinkName","ActionName",new {id=1,name"test"})%>

Post Status

Asked in February 2016
Viewed 1,603 times
Voted 9
Answered 1 times


Leave an answer

Quote of the day: live life