Thank you very much, Paramvir! That fixed it.
I have another issue with same code example with the excel export. I have two ASP.NET controllers set up to handle the post and get just like in Demo sample code. The excel file gets generated but with an error displayed when trying to open it
And then when it is opened it only shows the main rows and not any of the detail rows. I have attached two pictures to demonstrate what is happening.
Here are the two controller methods:
[HttpPost, ValidateInput(false)]
public String exportData(String pq_ext, String pq_data, bool pq_decode, String pq_filename)
{
String[] arr = new String[] { "csv", "htm", "json", "xlsx", "zip" };
if (arr.Contains(pq_ext))
{
String filename = pq_filename + "." + pq_ext;
Session["pq_data"] = pq_data;
Session["pq_decode"] = pq_decode;
Session["pq_filename"] = filename;
return filename;
}
else
{
throw new Exception("unsupported format!");
}
}
[HttpGet]
public FileContentResult exportData(String pq_filename)
{
if (Session["pq_filename"].ToString() == pq_filename)
{
String contents = Session["pq_data"].ToString();
byte[] bytes = ((bool)Session["pq_decode"]) ? Convert.FromBase64String(contents) :
new System.Text.UTF8Encoding().GetBytes(contents);
return File(bytes, "application/octet-stream", pq_filename);
}
else
{
throw new Exception("unknown file.");
}
}
Thoughts?
Thank you.