[英]Html.ActionLink Run My Action for several times in MVC C#
鉴于:
<%=Html.ActionLink(dr["ProductLinkLabel"].ToString(), "downloadFile", "Home", new { LinkID = dr["ProductLinkSN"]},null)%>
在控制器中:
[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);
}
Html.ActionLink
多次调用downloadFile
方法。 它必须一次运行,但是会随机调用方法
用这个
<%=Html.ActionLink("LinkName","ActionName",new {id=1,name"test"})%>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.