How to set encoding in C#?
I have a problem with 开发者_如何学Pythonencoding, I want to set encoding for example to HttpWebResponse resp
, everywhere where I look it says something like that resp.ContentEncoding = Encoding.UTF8
, but in practice that is wrong, because it says that ContentEncoding is a read-only property, please help me.
You need to differentiate between two similar-sounding but very different classes:
HttpWebReponse
is the response received in code from a web request. In other words, you don't get to set the data on it, because it was sent by another server.HttpResponse
is the response your code is sending from ASP.NET. This is the object you get to write your response data to... and theContentEncoding
property is writable.
精彩评论