optimus376
asked on
HttpContext Wierd Values
I writing out the content to HTTP response and I’m adding the header type as CSV. The exports works fine in local, QA and staging but in production I see a hex value at the beginning and 0 at the end. Since I’m not able to reproduce the same in local or QA I’m having a hard time debugging this. Have any of you seen this before ?
This is how I’m writing to response stream. The UI makes an http post to the ExportCSV.
[HttpPost]
public void ExportCSV()
{
HttpContextBase context = HttpContext;
context.Response.Clear();
context.Response.ContentTy pe = "text/csv";
context.Response.AddHeader ("Content- Dispositio n", "attachment; filename=" + "xxx" + Guid.NewGuid().ToString() + ".csv");
context.Response.Write("XX XXX”);
context.Response.End()
}
This is what I’m seeing in the export
22d (Hex value proportional to content length)
Data
0
This is how I’m writing to response stream. The UI makes an http post to the ExportCSV.
[HttpPost]
public void ExportCSV()
{
HttpContextBase context = HttpContext;
context.Response.Clear();
context.Response.ContentTy
context.Response.AddHeader
context.Response.Write("XX
context.Response.End()
}
This is what I’m seeing in the export
22d (Hex value proportional to content length)
Data
0
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It might help, I'm not sure. One thing that would be good to know is if the difference in in the actual string coming from the UI, or if the difference is being introduced when the string is processed for output. That would be a big clue as to what is going on.
ASKER
I changed the function return type as FileResult and returned a File(stream, filename) and it magically fixed things. THanks :)
ASKER
I've requested that this question be closed as follows:
Accepted answer: 0 points for optimus376's comment #a38745750
for the following reason:
Found the solution myself
Accepted answer: 0 points for optimus376's comment #a38745750
for the following reason:
Found the solution myself
ASKER
Response.ContentType = "text/csv; charset=utf-8"; will help ?