I want to call a method in the Web API controller on click of a button by passing the filename and GUID associated with the button in the View.
Here is the code.
<div style="float: left; width: 75%; margin-left: 10px;">
@(Html.Telerik().Grid((IEnumerable<FileModel>)ViewData["DocumentList"]).Name("DocumentList").Template(@text @Html.ActionLink("FileDownload", "FileDownload", new { file = item.FileName, GuID = item.DocumentGuID }) /text).Width(10);
In the above code I was calling FileDownload Action by passing FileName and GUID as parameters.
Now I want to call a method in samplecontroller and pass “Filename” and “Guid” as parameters.
public samplecontroller:webapicontroller
{
public downLoad(int,guid)
}
How can I call the method “downLoad” on click of button in view?
With ApiController most probably you need to use javascript to call the method async. Jquery will help Something like below:
There are other options though on how you pass the filename and guid and format the Uri request with UriTemplate.