473,394 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

HttpWebResponse Question

I ham tryin to access a website, the first time i send a GET to display the
first page it displays the HTML code, but always with text "Enable Cookies In
Your Browser", is there a way to have it not display that and display the
actual page, i did get it at some stage, ut that involved a bit of recursion,
by callin the method again (from within itself) and that allowed the page to
be displayed.

But when i have tried to call a POST request, it displays the Enable Cookies
In Your Browser page again, and this time, on amount of recursion can save it.

Any ideas, if u need this to be more clearly displayed, ill send some code
over
Nov 17 '05 #1
3 1821
Thaynann,

Are you setting any cookies to begin with? Also, are you setting the
UserAgent property correctly? Sites will typically gauge the abilities of a
browser based on the user agent string. You might want to change it to
something that IE uses.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ca*******@caspershouse.com

"Thaynann" <Th******@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
I ham tryin to access a website, the first time i send a GET to display the
first page it displays the HTML code, but always with text "Enable Cookies
In
Your Browser", is there a way to have it not display that and display the
actual page, i did get it at some stage, ut that involved a bit of
recursion,
by callin the method again (from within itself) and that allowed the page
to
be displayed.

But when i have tried to call a POST request, it displays the Enable
Cookies
In Your Browser page again, and this time, on amount of recursion can save
it.

Any ideas, if u need this to be more clearly displayed, ill send some code
over

Nov 17 '05 #2
"Enable cookies in your browser" would indicate that the web server is
determining (accurately or not) that your client does not have cookies
enabled. The "client" in this case is the HttpWebResponse object. I
have not encountered this particular problem but here are some thoughts
that occur to me offhand:

1) Is the target page part of a secure area such that it's looking for
some kind of credential cookie? It's possible that the reason it has
worked intermittently in the past is that you interactively accessed the
page, established your credentials, and that cookie was in the cache
when your program went back a little later to access the page.

2) Can you figure out what test the target page is using to test for
cookies being enabled? Armed with that knowledge, can you give it the
response it's looking for? Possibly something involving the Cookies
property of HttpWebResponse?

--Bob

Thaynann wrote:
I ham tryin to access a website, the first time i send a GET to display the
first page it displays the HTML code, but always with text "Enable Cookies In
Your Browser", is there a way to have it not display that and display the
actual page, i did get it at some stage, ut that involved a bit of recursion,
by callin the method again (from within itself) and that allowed the page to
be displayed.

But when i have tried to call a POST request, it displays the Enable Cookies
In Your Browser page again, and this time, on amount of recursion can save it.

Any ideas, if u need this to be more clearly displayed, ill send some code
over

Nov 17 '05 #3
firstly, thanx for the reply
i set the user agent as this;
webRequest.UserAgent = @"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;
..NET CLR 1.1.4322)";
as far as i know its wat IE can use (i ran TcpTrace to find out)
i have a global var (cookies) which is a CookieCollection object and im
doing this before i get a response )ie right after sendin a request

webRequest.CookieContainer = new CookieContainer();
if (this.cookies != null && this.cookies.Count > 0)
webRequest.CookieContainer.Add(this.cookies);

and this after i get a response, im new to web dev in c#, so i put most of
this together with examples i found
webResponse.Cookies =
webRequest.CookieContainer.GetCookies(webRequest.R equestUri);

if (webResponse.Cookies.Count > 0)
if (this.cookies == null)
{
this.cookies = webResponse.Cookies;
}
else
{
foreach (Cookie respCookie in webResponse.Cookies)
{
bool bMatch = false;
foreach(Cookie reqCookie in this.cookies)
{
if (reqCookie.Name == respCookie.Name)
{
reqCookie.Value = respCookie.Name;
bMatch = true;
break;
}
}
if (!bMatch)
this.cookies.Add(respCookie);
}
}
im not sure if it requires credientials (like a usrname and pass), im am
accessing a Online Manager for my fax machine (it has its own IP address) but
has never asked my for any info when i access it via IE.
"Bob Grommes" wrote:
"Enable cookies in your browser" would indicate that the web server is
determining (accurately or not) that your client does not have cookies
enabled. The "client" in this case is the HttpWebResponse object. I
have not encountered this particular problem but here are some thoughts
that occur to me offhand:

1) Is the target page part of a secure area such that it's looking for
some kind of credential cookie? It's possible that the reason it has
worked intermittently in the past is that you interactively accessed the
page, established your credentials, and that cookie was in the cache
when your program went back a little later to access the page.

2) Can you figure out what test the target page is using to test for
cookies being enabled? Armed with that knowledge, can you give it the
response it's looking for? Possibly something involving the Cookies
property of HttpWebResponse?

--Bob

Thaynann wrote:
I ham tryin to access a website, the first time i send a GET to display the
first page it displays the HTML code, but always with text "Enable Cookies In
Your Browser", is there a way to have it not display that and display the
actual page, i did get it at some stage, ut that involved a bit of recursion,
by callin the method again (from within itself) and that allowed the page to
be displayed.

But when i have tried to call a POST request, it displays the Enable Cookies
In Your Browser page again, and this time, on amount of recursion can save it.

Any ideas, if u need this to be more clearly displayed, ill send some code
over

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Denny Rue | last post by:
I’ve created VB code to download files from a web site through the use of HTTPWebRequest, HTTPWebResponse and BinaryReader. The HTTPWebRequest has a TimeOut property to limit how long it waits...
0
by: Prasanna Padmanabhan | last post by:
I get an empty CookieCollection when I do HttpWebResponse.Cookies. However HttpWebResponse.Headers returns the correct list of cookies (represented as a comma-separated string) in the reponse. ...
0
by: hlabbott | last post by:
Hi I'm having a problem displaying attachments correctly. I have messages with attachments stored on Exchange2000 and want to be able to click a hyperlink in my project like in OWA and see an...
13
by: Jason Manfield | last post by:
For some URLs (e.g.http://v3.espacenet.com/origdoc?DB=EPODOC&IDX=WO2005028634&F=0&QPN=WO2005028634), the content length for the HttpWebResponse I get with request.GetResponse in empty. The...
1
by: Jason Manfield | last post by:
Why does HttpWebResponse.CharacterSet always return ISO-8859-1? I am accessing a Chinese Web site (http://cn.yahoo.com) -- View Source in IE shows the character set to be "gb2312", but the...
16
by: Cheung, Jeffrey Jing-Yen | last post by:
I have a windows form application that generates a request, downloads an image, and waits the user to enter in login info. Unfortunately, this image is dynamic and based on session data. I have...
2
by: Nuno Magalhaes | last post by:
In pages that there is no content length, how does HttpWebResponse knows where the page ends? And what kind of objects/methods does it retrieve? Does it only retrieve the initial page without any...
2
by: Mr Flibble | last post by:
Hey! I get a 404 from a website (this is "correct behaviour") and I'm interested in the value in the cookie "SMSESSION". The question is the following code generates an exception due to the...
4
by: Hexman | last post by:
Code below ---- I've asked a similar question on this forum earlier. This is a slightly different situation. Previous Question ---- I'm trying to save some specific web pages to disk as...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.