TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Elisheva Cowan
NA
18
3.2k
file returning from webApi with gibberish characters
Mar 4 2020 7:46 AM
receiving file from webApi with gibberish characters when file contains characters in different language.
I tried setting encoding on header but not helping. Please advise.
var dataBytes = File.ReadAllBytes(result.ReturnValue.ToString());
string fileName = Path.GetFileName(result.ReturnValue.ToString());
var dataStream = new MemoryStream(dataBytes);
HttpResponseMessage httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK);
httpResponseMessage.Content = new StreamContent(dataStream);
httpResponseMessage.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
httpResponseMessage.Content.Headers.ContentDisposition.FileName = fileName;
httpResponseMessage.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
httpResponseMessage.Content.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");
//httpResponseMessage.Content.Headers.Add("Content-Transfer-Encoding", "utf-8");
//httpResponseMessage.Content.Headers.Add("charset", Encoding.ASCII.ToString());
//httpResponseMessage.Content.Headers.Add("charset", "utf-8");
//httpResponseMessage.Content.Headers.ContentEncoding.Add("gzip");
httpResponseMessage.Content.Headers.ContentEncoding.Add("utf-8");
return httpResponseMessage;
Reply
Answers (
17
)
Web API,Asp.Net,Angular 1x
What is the use of JWT token ?