Why can't access this site with WebReqest?

S

Sin Jeong-hun

If you type directly this address
http://www.parkoz.com/zboard/login_check.php?user_id=xxx&password=xxxx&auto_login=false
into your browsers (IE or Opera) and press enter, it shows a page
anyway.
But in the following code, just throws a time-out exception.
I think the server is checking the client somehow, and decided that my
application is not a normal web browser. Some sites seem to check
referer string, but in this case, I disabled referer and cookie in
Opera, but it was still displayed in Opera.
Do you have any idea?


HttpWebRequest req=(HttpWebRequest)
HttpWebRequest.Create("http://www.parkoz.com/zboard/login_check.php?user_id=xxx&password=xxxx&auto_login=false");
req.CookieContainer=new CookieContainer();
req.UserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)";
req.Timeout=2000;
req.Referer="http://www.parkoz.com";
req.KeepAlive=true;
WebResponse res;
res=req.GetResponse();
StreamReader sr=new StreamReader
(res.GetResponseStream(),System.Text.Encoding.Default);
string temp=sr.ReadLine();
sr.Close();
res.Close();
System.Diagnostics.Debug.Write(temp);
 
V

Vadym Stetsyak

Hello, Sin!

SJh> If you type directly this address
SJh> http://www.parkoz.com/zboard/login_check.php?user_id=xxx&password=xxxx
SJh> &auto_login=false into your browsers (IE or Opera) and press enter, it
SJh> shows a page anyway.
SJh> But in the following code, just throws a time-out exception.
SJh> I think the server is checking the client somehow, and decided that my
SJh> application is not a normal web browser. Some sites seem to check
SJh> referer string, but in this case, I disabled referer and cookie in
SJh> Opera, but it was still displayed in Opera.
SJh> Do you have any idea?

Probably some http headers are missing ( e.g. accept ).
You can install fiddler application to browse for http headers and include missed ones in your HttpWebRequest
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
V

Vadym Stetsyak

HttpWebRequest has properties Accept, ContentType, Method, Expect etc. These properties correspond to appropriate http headers

here are sample headers
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.6) Gecko/20040113
accept-language: en-us,en;q=0.5
accept-encoding: gzip,deflate
accept-charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
keep-alive: 300
Host: localhost
Connection: Keep-Alive

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top