473,847 Members | 1,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1836
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*******@caspe rshouse.com

"Thaynann" <Th******@discu ssions.microsof t.com> wrote in message
news:C4******** *************** ***********@mic rosoft.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.User Agent = @"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 CookieCollectio n object and im
doing this before i get a response )ie right after sendin a request

webRequest.Cook ieContainer = new CookieContainer ();
if (this.cookies != null && this.cookies.Co unt > 0)
webRequest.Cook ieContainer.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.Coo kies =
webRequest.Cook ieContainer.Get Cookies(webRequ est.RequestUri) ;

if (webResponse.Co okies.Count > 0)
if (this.cookies == null)
{
this.cookies = webResponse.Coo kies;
}
else
{
foreach (Cookie respCookie in webResponse.Coo kies)
{
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.Ad d(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
2123
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 for a corresponding HTTPWebResponse. This works just fine. However, the timeout does not appear to apply to a BinaryReader created from the HTTPWebResponse. I’ve had instances where the procedures will hang indefinitely during the download. ...
0
275
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. Can someone please explain the discrepancy? Thanks, Prasanna
0
10334
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 attachment. Because it is stored on Exchange I have to set a username and password so I do a GET request. The data I get back seems to still be encoded - trying to open an excel file for example results in it trying to open it but an excel...
13
9837
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 response.GetResponseStream() also empty. However, I am able to open the URL in the browser (the URL address remains the same; it is not redirected) Here is the code snippet: HttpWebRequest req = (HttpWebRequest)WebRequest.Create(pageAddress);
1
3313
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 HttpWebResponse shows it to be ISO-8859-1. Websites like www.cnn.com also show the character set to ISO-8859-1 Here is the code snippet: string pageAddress = "http://cn.yahoo.com"; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(pageAddress);
16
11067
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 read documents on the CookieCollection property of HttpWebRequest. Currently, I have the functionality in my code to be able to accept cookies, and return them upon a new HttpWebRequest; however, upon further inspection of the returning...
2
2394
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 images, i.e., does it only makes one "GET / HTTP/1.1\r\n\r\n"? Because I'm doing some projects on a webclient (to measure some statistic times) and the total bytes get byte HttpWebResponse are lower than the total objects I get via socket way. ...
2
3404
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 404. How am I still able to read the cookies even though I get an exception? Here's the code:
4
10911
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 text files. I searched the Internet and found a basic example which I changed to fit my needs. I tested it out first on a single URL and it worked fine. Now when I incorporate an array of URL's, it fails to work. The first "responseFromServer"...
0
9892
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10991
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10718
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7061
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5725
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5915
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3168
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.