Im using WebClient to download a webpage from a norwegian website. And in the downloaded data all special characters (øæå) are missing and replaced by a question mark type char instead.
I used to have this issue on my webpage before I added a "" in my html file, this is present here.
If I open a browser and browse to the address everything looks fine.
I have used fiddler to see exactly what headers I need to send and I am use im sending everything the exact same as my brower.
So by power of deduction I believe that WebClient is the offender, and somehow cripples the data before returning it to me, and im not sure how to stop him from doing this.
For more information this is my code to get the webpage:
string result = string.Empty;
using (WebClient client = new WebClient())
{
client.Headers["Accept"] = "application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
client.Headers["Referer"] = "http://mywebsite.no/forum/viewforum.php?f=7";
client.Headers["Accept-Language"] = "nb-NO";
client.Headers["User-Agent"] = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; AskTbFXTV5/5.9.1.14019)";
client.Headers["Accept-Encoding"] = "gzip, deflate";
using (Stream stream = client.OpenRead(new Uri(textBox1.Text)))
{
using (StreamReader reader = new StreamReader(stream))
{
result = reader.ReadToEnd();
}
}
}
Any tips?