I am unable to use the downloadfile() method in an aspx file as the server keeps returning 'unauthorised' error. The server is a out-the-box windows 2003 server, I'm I missing some setting in the IIS6 config as the download file location is set for everyone
to have read/write access
Where exactly are you storing the downloaded file? If you don't give it an explicit path it'll try to save it in x:\Windows\system32 which is a taboo. Also, if it still fails make sure ASPNET (or NETWORK SERVICE) account has appropriate access to the folder
where the downloaded file lands.
The file is being saved into a specific folder i.e. src_file="e:\inetpub\testsite\downloads\test.gif" and local user ASPNET user has full control even the most basic test fails e.g. Dim src_file As String = "d:\inetpub\testsite\downloads\logo.gif" Dim wc As
New Net.WebClient() wc.DownloadFile("http://www.google.com/images/logo.gif", src_file) this still returns a 401 Unauthorised
rrugrats63
Member
10 Points
2 Posts
webclient > downloadfile() authorisation
Feb 23, 2004 02:37 PM|LINK
MilanNegovan
Participant
1421 Points
296 Posts
MVP
Re: webclient > downloadfile() authorisation
Feb 23, 2004 06:40 PM|LINK
http://www.AspNetResources.com
ASP.NET With Emphasis On Web Standards
rrugrats63
Member
10 Points
2 Posts
Re: webclient > downloadfile() authorisation
Feb 27, 2004 08:30 AM|LINK
Jigar
Contributor
4629 Points
935 Posts
Try HttpWebRequest instead of web client.
Feb 27, 2004 01:34 PM|LINK
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://www.google.com/images/logo.gif"); HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse(); Stream s = myResponse.GetResponseStream(); Byte[] pageData = new byte[myResponse.ContentLength]; s.Read(pageData,0,pageData.Length); FileStream fs = new FileStream("d:\inetpub\testsite\downloads\logo.gif",FileMode.OpenOrCreate, FileAccess.Write); fs.Write(pageData, 0,pageData.Length); fs.Close();-----------------------
Do not forget to "Mark as Answer" on the post that helped you.