开发者

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 the ContentEncoding property is writable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜