Я работаю над проектом MVC4 с devexpress с пользовательским экспортом в код excel. Код хорошо работает на моем местном. Я могу загрузить файл xls без каких-либо проблем, но когда я развернулся на сервере, я получаю ошибку 404, когда я нажимаю на экспорт в excel.экспорт в excel 404 выпуск на сервере в mvc4
Я проверил разрешение, каждый имеет полный контроль.
Вот мой код для экспорта в Excel:
public ActionResult ExportToExcel(DateTime startDate, DateTime endDate)
{
try
{
GridView gridView = new GridView();
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "ShopFloorReport" + DateTime.Now.ToString("MM-dd-yyyy_HH:mm") + ".xls"));
Response.ContentType = "application/ms-excel";
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
gridView.AllowPaging = false;
gridView.DataSource = ReportExecutor.GetShopReportExportData(startDate, endDate);
gridView.DataBind();
//This will change the header background color
gridView.HeaderRow.Style.Add("background-color", "#FFFFFF"); //
//This will apply style to gridview header cells
for (int index = 0; index < gridView.HeaderRow.Cells.Count; index++)
{
gridView.HeaderRow.Cells[index].Style.Add("background-color", "#778899"); //Light Slate Gray
gridView.HeaderRow.Cells[index].Style.Add("foreground-color", "#ffffff"); // White
}
int index2 = 1;
//This will apply style to alternate rows
foreach (GridViewRow gridViewRow in gridView.Rows)
{
gridViewRow.BackColor = Color.White;
if (index2 <= gridView.Rows.Count)
{
if (index2 % 2 != 0)
{
for (int index3 = 0; index3 < gridViewRow.Cells.Count; index3++)
{
gridViewRow.Cells[index3].Style.Add("background-color", "#e6e6fa");// Lavender
}
}
}
index2++;
}
gridView.RenderControl(htmlTextWriter);
Response.Write(stringWriter.ToString());
Response.End();
}
catch
{
}
return null;
}