Re: HttpWebResponse Question
- From: "Thaynann" <Thaynann@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 11 Sep 2005 22:33:03 -0700
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.RequestUri);
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
>
.
- References:
- HttpWebResponse Question
- From: Thaynann
- Re: HttpWebResponse Question
- From: Bob Grommes
- HttpWebResponse Question
- Prev by Date: Re: Type Casting With Generics
- Next by Date: Re: CreateUser with LDAP?
- Previous by thread: Re: HttpWebResponse Question
- Next by thread: C# .Net V2, Strong Type Dataset returning more than one row.
- Index(es):
Relevant Pages
|