PC Review


Reply
Thread Tools Rate Thread

Another question regarding HTTPWebRequest

 
 
Nick Jacobsen
Guest
Posts: n/a
 
      15th Aug 2003
I am using HTTPWebRequest to connect to a server which requires
authentication, then responds with a 302 redirect message, and redirects to
DIFFERANT server, which also requires authentication (the same credentials
as the first server). My problem is I can get my client to authenticate to
the first server, and redirect to the first server, but then when the second
server responds with a 401 authentication required message, HTTPWebRequest
does not try to authenticate again... any suggestions?

TIA
Nick Jacobsen


 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      15th Aug 2003
"Nick Jacobsen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I am using HTTPWebRequest to connect to a server which requires
> authentication, then responds with a 302 redirect message, and redirects

to
> DIFFERANT server, which also requires authentication (the same credentials
> as the first server). My problem is I can get my client to authenticate

to
> the first server, and redirect to the first server, but then when the

second
> server responds with a 401 authentication required message, HTTPWebRequest
> does not try to authenticate again... any suggestions?


Nick,

My guess is that HttpWebRequest doesn't know it's a different server
returning the 401, so it thinks the authentication failed. Maybe if you turn
off automatic redirections and redirect on your own, the 401 from the second
server will be the only 401 HttpWebRequest sees.
--
John Saunders
Internet Engineer
(E-Mail Removed)


 
Reply With Quote
 
feroze
Guest
Posts: n/a
 
      18th Aug 2003
Since you have different servers that are requiring same credentials, you
should use the CredentialCache, instead of NetworkCredential on the request.
This is how you do it:

CredentialCache cache = new CredentialCache();
cache.Add(new Uri(http://server1/path1), "digest", new
NetworkCredential("user1", "pass1", "dom1"));
cache.Add(new Uri(http://server2/path2), "digest", new
NetworkCredential("user1", "pass1", "dom1"));
req.Credentials = cache;

Now, the webrequest will know that there is a credential for the second
server, and will use those for the second request. Just change the above
lines to suit your needs.

==========================
This posting is provided as-is. It does not offer any warranties and confers
no rights.


"John Saunders" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Nick Jacobsen" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Yes, that works, but creating a new connection for each redirect

> drastically
> > slows things down... I was hoping for either a fix for this, or for

this
> to
> > be confirmed as a bug... or for an explination of the reason it behaves
> > this way, since IE handles it fine...

>
> Wasn't it going to use two connections anyway? One per server?
>
> If it starts using more than the two, please post the info here. It's
> looking like I'm going to need to do the same thing soon.
> --
> John Saunders
> Internet Engineer
> (E-Mail Removed)
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HttpWebRequest ->HttpWebResponse question =?Utf-8?B?TWFyaw==?= Microsoft Dot NET Framework 2 24th Mar 2005 05:19 PM
HttpWebRequest question Tom Jones Microsoft C# .NET 1 2nd Jan 2005 08:52 PM
Another question regarding HTTPWebRequest Nick Jacobsen Microsoft Dot NET 2 18th Aug 2003 06:42 AM
Another question regarding HTTPWebRequest Nick Jacobsen Microsoft Dot NET Framework 2 18th Aug 2003 06:42 AM
HttpWebRequest question EMonaco Microsoft Dot NET Framework 2 16th Aug 2003 04:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:27 AM.