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

Problem downloading a file saved by htaccess over a proxy with authentication

Hello NG,

i have a problem With WebRequest!

i want to download a htaccess saved file over a proxyconnetion with
authentication.
Download a file what is not saved with htaccess is no problem, download a
htaccess saved file with out a
proxy with authentication i also no problem, but download this file with
htaccess and the auth proxy is a prob!

i use following code:
perhaps someone can help!

private void download()
{
string username = "user1";
string password = "password1";
string url = "proxyurl";
string dlurl "dlurl";
FileStream f = null;

NetworkCredential proxyCred = new NetworkCredential("user2",
"password2");
string[] localResources = {"192.168.*.*"};
WebProxy proxy = new WebProxy(new Uri("http://" +
url),true,localResources,proxyCred);

WebRequest request = WebRequest.Create(new Uri("http://" + dlurl));

request.Proxy = proxy;
if (username != "" && password != "")
{
NetworkCredential webCred = new NetworkCredential(username,
password);
request.Credentials = webCred;
}
try
{
request.Method = "GET";
request.ContentType = "binary/octet-stream";

WebResponse r = request.GetResponse();
long l = r.ContentLength;
System.IO.Stream respstream= r.GetResponseStream();

f = new FileStream("d:\\file.zip", FileMode.OpenOrCreate,
FileAccess.Write);
int BufferSize = 256;
byte[] recvbuffer = new byte[BufferSize];

long b = 0;
while (b < l)
{
int bytesread = respstream.Read(recvbuffer, 0, BufferSize);
f.Write(recvbuffer, 0, bytesread);
b += bytesread;
}
}
catch (System.Net.WebException ex)
{
MessageBox.Show(ex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (f != null)
f.Close();
}
}

Looking forward for some help

Jörg Braun
Nov 16 '05 #1
0 1649

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

Similar topics

4
by: bmiras | last post by:
I've got a problem using urllib2 to get a web page. I'm going through a proxy using user/password authentification and i'm trying to get a page asking for a HTTP authentification. And I'm using...
15
by: Ron L | last post by:
We are working on a distributed VB.Net application which will access a SQL database located on a known server. Each client will run on the user's local machine. To implement this, we are trying...
2
by: Volki | last post by:
I am using file upload download aspx code on my IIS 6.0, FW 1.1. I am uploading the files properly. However I am having problems on downloading the files in this code. Most of the browers I do not...
1
by: Alessandro Fachin | last post by:
I write this simply code that should give me the access to private page with htaccess using a proxy, i don't known because it's wrong... import urllib,urllib2 #input url...
4
by: John | last post by:
Hi I am publishing a vb.net app to a remote ftp/web site. This seems to go successfully. Once I try to install the app by using the url http://www.mydomain.com/publish.htm and pressing the Run...
4
by: c83 | last post by:
I am using Active Perl, and i-am having problems downloading files from internet because of the proxy. The script is workin when no proxy is present, but now it refuses to download files. Here is...
3
by: bryanp10 | last post by:
I have a web application where the admin wants to be able to upload arbitrary files on an admin page... and then have them accessible for certain users. Easy enough eh? The difficulty I'm...
2
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...
4
by: Jon | last post by:
I wrote a VS 2005 C# express programme that accesses a web service. It works fine when there's a direct connection to the internet, but on two different PCs with internet access via a proxy, I get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
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
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
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.