在 ASP.NET MVC 中,我试图通过帖子下载文件并发送 JSON 数据。此 JSON 数据是通过 knockout.js 在页面上显示的数据的过滤器。条件对象始终为空。如何通过 javascript 或表单帖子发送帖子数据来下载文件?我已经使用 GET 完成了 ajax 下载,但现在我有额外的数据,比如我需要发布的数组。
形式
<form method="POST" action="@Model.ExportUrl" >
<input type="hidden" name="criteria" data-bind="value: ko.toJSON(data())" />
<button class="btn"><i class="icon-download-alt"></i> Export</button>
</form>
要求
Request URL:http://localhost:2222/members/eventteams/export?eventId=8998
Request Method:POST
Status Code:500 Internal Server Error
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:128
Content-Type:application/x-www-form-urlencoded
Host:localhost:2222
Origin:http://localhost:2222
Referer:http://localhost:2222/members
User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36
Query String Parametersview sourceview URL encoded
eventId:8998
Form Dataview sourceview URL encoded
criteria:{"page":1,"pageSize":"100","sortOrder":"Team.Name","sortDirection":"ASC"}
控制器
[HttpPost]
public virtual ActionResult Export(int eventId, DivisionTeamsTableCriteria criteria)
{