简体   繁体   English

Html.ActionLink在MVC C#中多次运行“我的操作”

[英]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 by Html.ActionLink for several times. Html.ActionLink多次调用downloadFile方法。 It must run at once, but call method random times 它必须一次运行,但是会随机调用方法

用这个

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM