c# mvc return JSON or File from AJAX call

后端 未结 4 815
花落未央
花落未央 2021-01-14 00:30

I have something like this in my View:

        var url = \'@Url.Action(\"DownloadZip\", \"Program\")\' + \'?programNums=\' + selectedRow;

        $.ajax({
          


        
4条回答
  •  迷失自我
    2021-01-14 01:14

    Ajax: window.location = '/Home/download';

    c#:

            public FileResult download()
            {
               return File("~/" + path, "application/pdf", string.Format(fileName));
            }
    

提交回复
热议问题