473,385 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

"The Remote server returned an error :(407) Proxy Authentication Required "

Hi All,
I have an windows application created in C# &it is running fine on
several of our customer.
It does a httpWebrequest in the background.
Everything was working fine but some customer are facing
"The Remote server returned an error :(407) Proxy Authentication
Required "
{
WebRequest request = WebRequest.Create("http://TServer.com/
WebForm2.aspx");
string Text = "Question";
request.Method = "POST";
string postData = "TextBox1="+Text;
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
Console.WriteLine(((HttpWebResponse)response).Stat usDescription);
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
Console.WriteLine(responseFromServer);
reader.Close();
dataStream.Close();
response.Close();
}

Please Help me out!!

Oct 31 '07 #1
3 25792
On Oct 31, 6:37 am, "Learning.Net" <sanjay.btech2...@gmail.comwrote:
I have an windows application created in C# &it is running fine on
several of our customer.
It does a httpWebrequest in the background.
Everything was working fine but some customer are facing
"The Remote server returned an error :(407) Proxy Authentication
Required "
Well, the first thing that's wrong with the code is that it can leak
connections etc if an exception is thrown. Use "using" blocks for
everything that implements IDisposable, such as Stream and
WebResponse.

However, that's not the cause of the issue. The cause is fairly well
described by the exception - you'll need to set a proxy for the web
request (set WebRequest.Proxy), specifying appropriate authentication.
You'll probably need to provide some way of the user configuring this.

Jon

Oct 31 '07 #2
On Oct 31, 1:18 pm, "Jon Skeet [C# MVP]" <sk...@pobox.comwrote:
On Oct 31, 6:37 am, "Learning.Net" <sanjay.btech2...@gmail.comwrote:
I have an windows application created in C# &it is running fine on
several of our customer.
It does a httpWebrequest in the background.
Everything was working fine but some customer are facing
"The Remote server returned an error :(407) Proxy Authentication
Required "

Well, the first thing that's wrong with the code is that it can leak
connections etc if an exception is thrown. Use "using" blocks for
everything that implements IDisposable, such as Stream and
WebResponse.

However, that's not the cause of the issue. The cause is fairly well
described by the exception - you'll need to set a proxy for the web
request (set WebRequest.Proxy), specifying appropriate authentication.
You'll probably need to provide some way of the user configuring this.

Jon
Thanks for the help!!
How user can configure the proxy ? Please help me with some code
snippet.

Nov 5 '07 #3
On Nov 5, 9:32 am, "Learning.Net" <sanjay.btech2...@gmail.comwrote:
However, that's not the cause of the issue. The cause is fairly well
described by the exception - you'll need to set a proxy for the web
request (set WebRequest.Proxy), specifying appropriate authentication.
You'll probably need to provide some way of the user configuring this.

Thanks for the help!!
How user can configure the proxy ? Please help me with some code
snippet.
The easiest thing would be for them to configure their system proxy
through IE appropriately - then I *believe* it should just work by
default.

Otherwise, you'll need to provide some configuration user interface,
and then build a WebProxy instance based on that.

Jon

Nov 5 '07 #4

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

Similar topics

1
by: Tomas Christiansen | last post by:
Im trying to make a simple TCP socket "relay" or "proxy", but my skills in Python are not high (yet). The only thing it should do, is to open the connection on behalf of the client, and when the...
3
by: Alan Howard | last post by:
Hi there, I can't seem to find any info on this error message that's generated when sending email with CDO: "The pickup directory path is required and was not specified" Does anyone know...
1
by: Angel | last post by:
I'm trying to connect to a fixed IP address (eg. http://10.60.903.50/TempFile) in order to retrieve one accii line of text in TempFile. I try to read the information with this code: string...
0
by: thatrickguy | last post by:
Hi everyone. I am developing on a Windows XP sp2 machine with VS.Net 2002 installed. Windows firewall is disabled. I have a Windows 2k Server sp4 with IIS 5 and VS.Net 2002 installed....
0
by: lpinho | last post by:
Hi There, I've generated a C# file from a wsdl file using wsdl.exe utility. Then I created a console application and made a call to the method generated, first I got the error: "The request...
0
by: jens Jensen | last post by:
Hello, I'm trying to connect to a system via https. As an additional security measure, the server requires me to attach an x509 certs to my "HTTP POST" request. I get the error...
0
by: serge | last post by:
I have 2 SQL Enterprise Editions running SP2 and same collation. When i try to start database mirroring I get the following error message: "The remote copy of database "ABC" has not been...
0
by: =?Utf-8?B?R2VvcmdlIFNodWk=?= | last post by:
I have a folder structure such like this. A ---A1 -----a1.aspx ---A2 A1 and A2 are the subfolder of A. And under the A1 folder, it contains one aspx file named a1.aspx. I set the IIS virtual...
0
by: Brian Lampe | last post by:
On Apr 11, 7:25 am, subhash <chend...@hotmail.comwrote: If your service is using a port other than 80, you can specify it in the service instantiation's Url property: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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
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,...
0
jinu1996
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...

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.