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 3 2789
"Nick Jacobsen" <nj*******@pfas tship.com> wrote in message
news:uG******** ******@TK2MSFTN GP10.phx.gbl... 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 jo***********@s urfcontrol.com
Since you have different servers that are requiring same credentials, you
should use the CredentialCache , instead of NetworkCredenti al on the request.
This is how you do it:
CredentialCache cache = new CredentialCache ();
cache.Add(new Uri( http://server1/path1), "digest", new
NetworkCredenti al("user1", "pass1", "dom1"));
cache.Add(new Uri( http://server2/path2), "digest", new
NetworkCredenti al("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" <jo***********@ surfcontrol.com > wrote in message
news:eb******** ******@TK2MSFTN GP09.phx.gbl... "Nick Jacobsen" <nj*******@pfas tship.com> wrote in message news:Os******** ******@TK2MSFTN GP12.phx.gbl... 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 jo***********@s urfcontrol.com
Since you have different servers that are requiring same credentials, you
should use the CredentialCache , instead of NetworkCredenti al on the request.
This is how you do it:
CredentialCache cache = new CredentialCache ();
cache.Add(new Uri( http://server1/path1), "digest", new
NetworkCredenti al("user1", "pass1", "dom1"));
cache.Add(new Uri( http://server2/path2), "digest", new
NetworkCredenti al("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" <jo***********@ surfcontrol.com > wrote in message
news:eb******** ******@TK2MSFTN GP09.phx.gbl... "Nick Jacobsen" <nj*******@pfas tship.com> wrote in message news:Os******** ******@TK2MSFTN GP12.phx.gbl... 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 jo***********@s urfcontrol.com
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nick Jacobsen |
last post by:
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...
|
by: someone |
last post by:
I am in a situation where I need to package some information from
Page1, submit it via POST to another server which will process the
information and then send the user to another page on my server
(Page2).
I have looked at HttpWebRequest (see code below) on numerous coding
websites but have not found a method that works. Does anyone have a
solution for this or has seen an example that works for this
situation?
|
by: Rafael Zavulunov |
last post by:
Here's my question:
Our company has several web-apps and we're trying to create a central
login page as a separate web-app, which will then, based on the user's
selection, redirect the user to the correct app. Now, when a user logs
in, some info is retrieved from the DB and stored into an object,
which is serialized. I'm wondering if its possible to send the
serialized string from one aspx page to another, i was trying this:
|
by: thomas peter |
last post by:
I am building a precache engine... one that request over 100 pages on an
remote server to cache them remotely...
can i use the HttpWebRequest and WebResponse classes for this? or must i use
the MSHTML objects to really load the HTML and request all of the images on
site?
string lcUrl = http://www.cnn.com;
// *** Establish the request
|
by: R Reyes |
last post by:
Another error. I had my friend set up another server at his place and i
receieved this error. I think this means that the PUT/POST method was not
allowed or permissable on his side right?
File upload failed: System.Net.WebException: The remote server returned an
error: (405) Method Not Allowed. at
System.Net.HttpWebRequest.CheckFinalStatus() at
System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at...
| |
by: Rafael Zavulunov |
last post by:
Here's my question:
Our company has several web-apps and we're trying to create a central
login page as a separate web-app, which will then, based on the user's
selection, redirect the user to the correct app. Now, when a user logs
in, some info is retrieved from the DB and stored into an object,
which is serialized. I'm wondering if its possible to send the
serialized string from one aspx page to another, i was trying this:
|
by: someone |
last post by:
I am in a situation where I need to package some information from
Page1, submit it via POST to another server which will process the
information and then send the user to another page on my server
(Page2).
I have looked at HttpWebRequest on numerous coding websites but have
not found a method that works. Does anyone have a solution for this or
has seen an example that works for this situation?
This is one very frustrating issue that I...
|
by: Denise |
last post by:
I have posted a similar message in 2 other forums but got no response. I
have spent more hours than I can count researching this. Can anyone provide
some insight...?
Our ASP.Net application needs to transparently log a user on to a separate
secure web site (PHP - not controlled by us). We want to save the user the
step of typing in his username and password and having to press submit.
I could accomplish this by using the <form...
|
by: genojoe |
last post by:
I am looking for a VB.NET code that I can use to monitor an independent Web
Site, I would like to do an equivalent of a PING of the site every 5 minutes
or so and make sure that it returns the appropriate login is screen. I then
will use the response to send an email if the site is not responding properly.
I would think that somewhere on the Web this code exists but I could not
find it. Can someone point me to such a site?
|
by: sindhurasingeetham |
last post by:
Hi,
I'm new to coding in .NET. I am trying to do an asynchronous call in my code using httpwebrequest. This code works perfectly fine on one server, but does not work on another. The main flow works on the new server, but it somehow does not do the asynchronous calling part. I'm unable to see the async part hitting IIS (from the IIS logs) as well. I have compared the IIS settings on both the servers and they are the same. The settings on both...
|
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 project—planning, coding, testing, and deployment—without 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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |