Click here to Skip to main content
15,901,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, I need to download a file from a web server folder which uses a .htaccess file to restrict access to the contents - how do I set the authorization from a c# Winform app ?, I can download ok if I remove the .htaccess file

What I have tried:

Nothing except googling which hasn't helped me.
Posted
Updated 13-Mar-16 5:42am
Comments
Dave Kreskowiak 13-Mar-16 11:40am    
What does your download code look like?

1 solution

 
Share this answer
 
Comments
pkfox 14-Mar-16 4:26am    
Thanks Dave
pkfox 14-Mar-16 6:19am    
I tried those examples Dave and I still get a 401 not authorized error which is not surprising I suppose as the password stored in the .htpasswd file is encrypted - I used this site to generate it
http://www.htaccesstools.com/htpasswd-generator/

and it looks like this
pjk:$apr1$JhJmwyV4$cgtib4PXD9NxL0iGQeg2f1
Dave Kreskowiak 14-Mar-16 8:17am    
In those examples, the password is not encrypted. It's simply a string, "myusername:mypassword" encoded using Base64.

Base64 is not an encryption. Base64 - Wikipedia, the free encyclopedia[^]
pkfox 14-Mar-16 8:14am    
Apologies Dave this is what worked from one of those links

this.client.Credentials = new NetworkCredential("myusername", "myunencryptedpassword"); // where client is WebClient
I was trying it with the encrypted password before - works a treat

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900