Take the 2-minute tour ×

I'm writing a simple application that will download some piece of data from a website then I can use it later for any purpose.

The following is the request and response copied from Firebug as the browser did that. When you type http://x5.travian.com.sa/ajax.php?f=k7&x=18&y=-186&xx=12&yy=-192 you will get a PHP file has some data. But when I make a request with HttpWebRequest I get wrong data (some unknown letters)

Can anyone help me in that? Do I have to make some encodings or what?


 1. Server  nginx
 2. Date    Tue, 04 Jan 2011 23:03:49 GMT
 3. Content-Type    application/json; charset=UTF-8
 4. Transfer-Encoding   chunked
 5. Connection  keep-alive
 6. X-Powered-By    PHP/5.2.8
 7. Expires Mon, 26 Jul 1997 05:00:00 GMT
 8. Last-Modified   Tue, 04 Jan 2011 23:03:49 GMT
 10. Pragma no-cache
 11. Content-Encoding   gzip
 12. Vary   Accept-Encoding


 1. Host    x5.travian.com.sa
 2. User-Agent  Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv: 
 3. Gecko/20101203 Firefox/3.6.13
 5. Accept-Language en-us,en;q=0.5
 6. Accept-Encoding gzip,deflate
 8. Keep-Alive  115
 9. Connection  keep-alive
 10. Cookie CAD=57878984%231292375897%230%230%23%230; T3E=%3DImYykTN2EzMmhjO5QTM2QDN2oDM1ITOyoDOxIjM4EDN5ITM6gjO4MDOxIWZyQWMipTZu9metl2ctl2c6MDNxADN6MDNxADNjMDNxADNjMDNxADN; orderby_b1=0; orderby_b=0; orderby2=0; orderby=0
share|improve this question
add comment

3 Answers

I used wget on unix to hit the site, and I got back a page that had arabic characters in it. As per the response headers the page is encoded as UTF8.

If you can show the code you are using, we could provide feedback. Maybe there is a bug in your code in the way you are interpreting the response stream.

share|improve this answer
I solved the problem by making the right cookies –  Sami Abdelgadir Mohammed Jan 11 '11 at 15:00
add comment

Finally it is solved, the response was encoded with the gzib encode, so I just decode it with the gzibdecodestream...

share|improve this answer
add comment

AJAX => You probably need a web browser to render Javascript.

share|improve this answer
Why so many downvotes but no explanation? HttpWebRequest does not use a web browser and thus fails at complex Javascript - or? –  Alfredo2011 Jan 5 '11 at 0:42
dunno, possibly the site doesn't use ajax? Or does it? Update your answer with details if it does, I think it'll help you. –  Will Jan 5 '11 at 17:29
A site called ajax.php sounds like it uses ajax. I would love to check the site itself, but the link does not work. I only get a white page. –  Alfredo2011 Jan 5 '11 at 18:55
But I have another problem, when I download the expected file most of the data that represents some un english names came in the form \u0644 and so on... and I want it to be letters, how can I solve this? –  Sami Abdelgadir Mohammed Jan 11 '11 at 15:03
add comment

Your Answer


