471,610 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,610 software developers and data experts.

Why can't access this site with WebReqest?

If you type directly this address
http://www.parkoz.com/zboard/login_c...to_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_log in=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.Defa ult);
string temp=sr.ReadLine();
sr.Close();
res.Close();
System.Diagnostics.Debug.Write(temp);

Feb 14 '06 #1
2 1230
Hello, Sin!

SJh> If you type directly this address
SJh> http://www.parkoz.com/zboard/login_c...&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
Feb 14 '06 #2
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
Feb 14 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.