ContentDispositionHeaderValue FormatException

grtpuntakias

New Member
I'm trying to return a HttpResponseMessage that contains a csv file. I have code similar to the following:\[code\]HttpResponseMessage response;byte [] data = http://stackoverflow.com/questions/14509424/System.Text.UTF8Encoding.UTF8.GetBytes("this is my csv");response = new HttpResponseMessage(HttpStatusCode.OK){ Content = new StreamContent(new MemoryStream(data))};// CSV fileresponse.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment; filename=\"myfile.csv\";");response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/csv");return response;\[/code\]But I am getting an exception on the \[code\]ContentDispositionHeaderValue\[/code\] line. The exception is:\[code\]The format of value 'attachment; filename="myfile.csv";' is invalid.\[/code\]But I'm fairly certain this is valid. Obviously I must be wrong though. Could anyone point me at the proper format?
 
Back
Top