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:

    [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 by Html.ActionLink for several times. It must run at once, but call method random times

Answers


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

Search




Leave an answer