HTTP / 1.1 415不支持的媒体typesExcel文件Dawnload问题

我在Silverlight目录中有excel导出function。 用户将右键点击目录,这将通过浏览器触发下载。

public static void ExportValues(CatalogData data) { var excelData = new ExcelData { Sheets = new[] { data } }; string serializedData = excelData.Serialize(); HtmlPage.Window.Invoke("exportToExcel", serializedData); } 

这是javascript调用

 function exportToExcel(serializedData) { var formId = "exportToExcelForm"; var inputId = "SerializedExcelData"; var form = document.getElementById(formId), input; if (form == null) { form = document.createElement("form"); form.setAttribute("id", formId); form.setAttribute("method", "POST"); form.setAttribute("action", "../api/excel"); form.style.visibility = "hidden"; form.style.height = "0px"; form.style.width = "0px"; form.style.borderWidth = "0px"; document.body.appendChild(form); input = document.createElement("input"); input.setAttribute("id", inputId); input.setAttribute("type", "hidden"); input.setAttribute("name", inputId); form.appendChild(input); } else { input = document.getElementById(inputId); } input.setAttribute("value", serializedData); form.submit(); input.setAttribute("value", ""); 

}`

 [HttpPost] public static HttpResponseMessage GenerateExcel(ExcelDataWrapper wrapper) { ExcelData data = wrapper.Unwrap(); var content = new StreamContent(ExcelCreator.Create(data)); var clientDateTime = ExcelCreator.ClientDateTime; var fileName = "test.xlsx"; content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = fileName }; content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); return new HttpResponseMessage(HttpStatusCode.OK) { Content = content }; } 

问题是部署到IIS服务器时我收到错误HTTP / 1.1 415不支持的媒体types,请参阅提琴手

在这里输入图像说明

这个代码在我的机器上完全运行(Localhost) 在这里输入图像说明

无法find这里有什么问题