HttpWebRequest.GetResponse does not work on some uris

  • Thread starter Thread starter Anton Sommer
  • Start date Start date
A

Anton Sommer

Hello folks,

I made an application to request webpages from the internet and it works
fine on the most of the uris but with that specific uri I need to query it
does not work. That url would be:
http://v3.espacenet.com/family?sf=n...rorTemplate=ep/en/incerror.hts&ResultCount=10

with this I only get back a cookie and I get back Headers in the response
object but the stream is empty, not even an errormesage site from the
server.

What could be the cause? Any suggestions welcome


Thank you


Anton
 
Anton Sommer said:
Hello folks,

I made an application to request webpages from the internet and it works
fine on the most of the uris but with that specific uri I need to query it
does not work. That url would be:
http://v3.espacenet.com/family?sf=n...rorTemplate=ep/en/incerror.hts&ResultCount=10

with this I only get back a cookie and I get back Headers in the response
object but the stream is empty, not even an errormesage site from the
server.

What could be the cause? Any suggestions welcome

One possible cause is that the site may actually be sending you nothing.
 
Hello John thank you for answering,

One possible cause is that the site may actually be sending you nothing.

well it does definitely work in IE as you can test yourself by clicking on
the posted link, what possible causes are there? The site is definitely
returning a cookie and there is header information in the webresponse but
nothing in the stream. Could it possibly expect another clientside request
after returning the cookie? Who knows anything about it?


Thank you


Anton
 
Anton Sommer said:
Hello John thank you for answering,



well it does definitely work in IE as you can test yourself by clicking on
the posted link, what possible causes are there? The site is definitely
returning a cookie and there is header information in the webresponse but
nothing in the stream. Could it possibly expect another clientside request
after returning the cookie? Who knows anything about it?

Anton,

If it works with IE but not with your HttpWebRequest, then I'd suggest using
a network monitor like ProxyTrace from http://pocketsoap.com. If I were you
I'd look at the interaction between IE and the remote site, then look at the
interaction between your program and the remote site.

Differences would be instructive...
 
Thank you for answering John,


I'd look at the interaction between IE and the remote site, then look at the
interaction between your program and the remote site.

How could I do that?


Thank you

Anton
 
hi Anton,
this is not so complex..
just that you need to handle the cookies, and build a proper request
object and then get the response.
request = (HttpWebRequest)WebRequest.Create(UrlToSearch);
request.Method = "GET";
request.Accept = "*/*";
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)";
request.CookieContainer = cookies;
response = request.GetResponse();
stream = response.GetResponseStream();
HttpWebResponse webResponse =
(HttpWebResponse)request.GetResponse();
WebHeaderCollection headers = webResponse.Headers;
//check for cookies after this and add them to the cookies collection

//finsh handlig cookies
return stream;

NOTE: There is an article on the web on how to access hotmail from
c#.that should be a good reference.
hope this helps
regards,
Deepak

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
Back
Top