473,505 Members | 13,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Proxy Authentication

Hi All

In the .NET Framework is there any way to provide the proxy
authentication the way internet explorer prompts.

I mean when I access the net using internet explorer it asks for the
username and password. I want that when I create a Web-Request it also
prompts for the username and password for the proxy server exactly the
way it asks for the internet explorer.

Presently it just simply gives the error with 407 status code stating
that proxy authentication is required.
The code is as follows:
Uri myUri =new Uri("http://www.google.co.in/");
WebRequest client = WebRequest.Create(myUri);
client.Proxy = System.Net.WebProxy.GetDefaultProxy();
myResponse = client.GetResponse();
data = myResponse.GetResponseStream();
reader = new StreamReader (data);
String str = reader.ReadToEnd ();
Regards
Andrew

Nov 19 '05 #1
1 1260
The problem is: WebRequest can be used from all sorts of environments:
ASP.NET, Windows Forms, a background service, a Pocket PC. WebRequest
doesn't know how to prompt a user, not could it really be done in a
way that works under all these different environments. You'll have to
prompt and provide the information to WebRequest.

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On 6 Apr 2005 08:09:38 -0700, "Andrew"
<an******************@yahoo.com> wrote:
Hi All

In the .NET Framework is there any way to provide the proxy
authentication the way internet explorer prompts.

I mean when I access the net using internet explorer it asks for the
username and password. I want that when I create a Web-Request it also
prompts for the username and password for the proxy server exactly the
way it asks for the internet explorer.

Presently it just simply gives the error with 407 status code stating
that proxy authentication is required.
The code is as follows:
Uri myUri =new Uri("http://www.google.co.in/");
WebRequest client = WebRequest.Create(myUri);
client.Proxy = System.Net.WebProxy.GetDefaultProxy();
myResponse = client.GetResponse();
data = myResponse.GetResponseStream();
reader = new StreamReader (data);
String str = reader.ReadToEnd ();
Regards
Andrew


Nov 19 '05 #2

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

Similar topics

1
6338
by: Mark Ferguson | last post by:
I've been trying to get a simple pycurl script working with an authenticating proxy, here is the code (with changes to protect the guilty!): from pycurl import * import StringIO b =...
3
7752
by: Wild Wind | last post by:
Hello all, I apologise in advance for the long windedness of this post, but I feel that if I am going to get any solution to this problem, it is important that I present as much information...
1
10482
by: Vladimir Rypacek | last post by:
Hi, I've got strange error on computer which is accessing web-service thrugh proxy. Scenario 1 ---------- - the web-service does not require authentication (Anonymous access is allowed) -...
0
1195
by: Punit | last post by:
Hello, I have an unmanaged VC7 app (ActiveX control implemented using MFC) calling a C# dotnet service. I'm using the VS2003 generated proxy class derived from CSoapSocketClientT. The activeX...
7
15392
by: Pro1712 | last post by:
Hello, I need to write a simple proxy server. What I want to do is to use HttpListener to get requests from the browser, add some proxy information and some other stuff and send the request to...
2
11401
by: rcp | last post by:
Hi all, I've read all posts from all existing threads and none of them worked to solve my problem, although its exactly the same. I'll try to explain my case and see if a kind soul could help me...
4
5975
by: Boni | last post by:
I want consuming a webserivce trough a proxy. I use this code. myService s = new myService (); System.Net.WebProxy proxyObject = new System.Net.WebProxy("http://proxyhost:8080"); s.Proxy =...
1
4316
by: JohnH | last post by:
Hi, In my application which has two or more threads calling web service or just HttpWebRequest I am seeing some HTTP 400 errors retrun in the response. All the calls are going through the same ISA...
7
40937
by: chandru1782 | last post by:
Dear friends, I am trying to use CPAN for installing some perl modules. i am using a ubuntu system, which has internet connection through lan and authenticated proxy. when trying to install...
2
8122
by: =?Utf-8?B?TGVuc3Rlcg==?= | last post by:
A C# (.NET 2) application which uses the System.Net.HttpWebRequest object to request a resource over HTTPS is failing following the installation of a new proxy server on our internal network with...
0
7098
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...
0
7298
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,...
1
7017
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
7471
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...
0
4698
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...
0
3187
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...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1526
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 ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.