473,320 Members | 2,088 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,320 software developers and data experts.

System.Net.WebException Error - Please help

I have written a windows app to request a file from www.hotmail.com and
i get the following error:

************* Exception Text **************
System.Net.WebException: The remote server returned an error: (407)
Proxy Authentication Required.

My code:

private void Download(String strFinalURL)
{
WebRequest objWebRequest;
WebResponse objWebResponse;
FileStream objFileStream;
BufferedStream objBufferedStream;
Byte[] b = new Byte[1024];
//Byte[] b = new Byte[8192];
int iRead = 1;

objWebRequest = WebRequest.Create(strFinalURL);
objWebRequest.Credentials = CredentialCache.DefaultCredentials;

objWebResponse = objWebRequest.GetResponse();
this.lblSize.Text = objWebResponse.ContentLength.ToString() + "
Bytes";

objBufferedStream = new
BufferedStream(objWebResponse.GetResponseStream()) ;
//String strOutputFileName = TEMP_DIR + TEST_FILE + EXT;
String strOutputFileName = TEMP_DIR + this.txtFileNameLocal.Text +
"." + this.txtExt.Text;
objFileStream = new FileStream(strOutputFileName,
FileMode.OpenOrCreate,
FileAccess.Write);

long streamLen = objWebResponse.ContentLength;
float fLen = (float)streamLen;
long count = 0;

Console.Write("File downloaded");
objBufferedStream.Close();
objFileStream.Close();

}

Nov 17 '05 #1
6 7069
Hey SP Dude,

I think u r accessing Internet using proxy server. Am i right?

If i'm, do sd followd:

WebRequest objWebRequest;
WebResponse objWebResponse;

//****************New code -************
Net.WebProxy aProxy = new Net.WebProxy();
aProxy.Address = new Uri(serverAddress);
aProxy.Credentials = new System.Net.NetworkCredential(username,
password, domain);

objWebRequest.Proxy = aProxy;
objWebResponse.Proxy = aProxy
//*********** End of new code*******

The above will surly work....

Regards,

Ankit Jain,
http://www.ankitjain.info/

Nov 17 '05 #2
thanks ankit

any idea how i could find the serverAddress for the proxy?
AnkitAsDeveloper wrote:
Hey SP Dude,

I think u r accessing Internet using proxy server. Am i right?

If i'm, do sd followd:

WebRequest objWebRequest;
WebResponse objWebResponse;

//****************New code -************
Net.WebProxy aProxy = new Net.WebProxy();
aProxy.Address = new Uri(serverAddress);
aProxy.Credentials = new System.Net.NetworkCredential(username,
password, domain);

objWebRequest.Proxy = aProxy;
objWebResponse.Proxy = aProxy
//*********** End of new code*******

The above will surly work....

Regards,

Ankit Jain,
http://www.ankitjain.info/


Nov 17 '05 #3
Now I am getting this error:

System.Security.SecurityException: Request for the permission of type
System.Net.WebPermission, System, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 failed.

Any help?

Nov 17 '05 #4
R u on dialup connection ofr working for an organization. It's the
server address for using internet.U can check it in

"Control Panel > Internet Options > Connections > Lan Settings... "

Specifies to connect to the Internet through a proxy server by using
the settings you specify. A proxy server acts as an intermediary
between your internal network (intranet) and the Internet, retrieving
files from remote Web servers.
Ankit Jain, [http://www.ankitjian.info/ankit/]

Nov 17 '05 #5
R u on dialup connection ofr working for an organization. It's the
server address for using internet.U can check it in
"Control Panel > Internet Options > Connections > Lan Settings... "
Specifies to connect to the Internet through a proxy server by using
the settings you specify. A proxy server acts as an intermediary
between your internal network (intranet) and the Internet, retrieving
files from remote Web servers.
Ankit Jain, [http://www.ankitjain.info/ankit/]

Nov 17 '05 #6

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

Similar topics

0
by: Joe Bloggs | last post by:
I have a C# MRS application that uses the ReportingService's Render method to retrieve a byte array containing a report. The following error message occurs An unhandled exception of type...
2
by: genc_ ymeri at hotmail dot com | last post by:
Hi, I'm trying to recieve the response status code rather than the message in the below code : try { responseArray = myWebClient.UploadValues(uriString,"POST",myNameValueCollection); }...
1
by: etantonio | last post by:
Good morning, I've a problem, in the past I translate my site from google or altavista with a code similar to this : <%@ Page Language="c#" Trace="true" Debug="true" %> <%@ import...
0
by: Faiyaz | last post by:
Hello to EveryBody i'm Getting this Peculiar error System.ApplicationException: The remote server returned an error (400) Bad Request. - - > System.Net.WebException: The remote server...
2
by: tlan | last post by:
Hi, I got this error when I move my web service to Windows2003 server. I spent hours scouting on the internet and could find any answer. Please help!!! I the webservice is timeout between 1...
8
by: Tim Reynolds | last post by:
Our .Net application calls a web method of aplpication 2 that resides on their Apache server. When I as a developer C#, Studios 2003, make the call to their web method from my desktop, I receive no...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
20
by: djc | last post by:
I get this *intermittently* on a utility I am working on. I don't know whats going on but here are a few points about it: - using VS 2005, running on xp sp2 - program uses multiple threadpool...
1
by: roadie.girl | last post by:
Hey guys - I'm really new to this .NET programming so please bear with me ... (vb.NET) I'm trying to fill in the list contents of a combo box on the open event of a form. this list will list...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.