Tag: steam web api

从Asp Net Web API控制器导出到Excel

我正在使用新的Web应用程序,即使用Web API作为业务层和淘汰Js作为客户端框架工作进行绑定。 我有一个要求,如将一定的search条件传递给Web API控制器,并从数据库获取数据,并创build和发送Excel / MS-Word文件作为一个可下载的内容。 我对Web API和Knock都是新手,我在网上search并获得部分解决scheme,我正在寻找这个用例的更优化的解决scheme。 以下是我的代码: 客户: function GetExcelFile() { var $downloadForm = $("<form method='POST'>") .attr("action", baseUrl + "api/FileHandler/GetExcelFileTest") .attr("target", "_blank") $("body").append($downloadForm); $downloadForm.submit(); $downloadForm.remove(); } 点击button点击此代码片段即可创build表单并从Web API获取响应。 Web API代码: [HttpPost] public HttpResponseMessage GetExcelFileTest() { var response = new HttpResponseMessage(); //Create the file in Web App Physical Folder string fileName = Guid.NewGuid().ToString() + […]