How to implement file download with AJAX and MVC

后端 未结 4 1782
Happy的楠姐
Happy的楠姐 2021-02-07 20:06

I would like to provide a file download operation by using the jQuery AJAX call with some params under MVC

Example

(javascript)
function DoDownload(start         


        
4条回答
  •  余生分开走
    2021-02-07 20:51

    What I ended up doing is calling my controller from my javascript like:

    var url = "/mycontroller/GetFile?startDate=" + $("#mydate").val() + etc...
    
    window.location = url;
    

    mycontroller.cs

     public void GetFile(DateTime startDate) 
    {
    
    }
    

    My original concern was with the date parameters. I didnt want to have to parse it.

提交回复
热议问题