Thanks Keith for your reply.
I did think about that solution but its frustrating because its working on another site in the same farm.weird. Thanks anyways. From: [email protected] [mailto:[email protected]] On Behalf Of Keith Knight Sent: Tuesday, 8 December 2009 1:32 PM To: ozMOSS Subject: RE: Help! - webclient.downloadData Hi Trent, I ran into this issue a while back also - and couldn't find an easy solution. In the end I re-worked my code to use the SharePoint API and get the file as a SPFile instead (as it was always going to be stored in the same site collection as the web part that was running the code). It seemed to work in our scenario, not sure if it's applicable to yours but maybe worth considering. Interested to know if anyone has solved it? Cheers, Keith _____ From: [email protected] [[email protected]] On Behalf Of Trent Allday [[email protected]] Sent: Monday, 7 December 2009 1:27 PM To: 'ozMOSS' Subject: RE: Help! - webclient.downloadData Hi Paul, I currently have anonymous access ticked for the web app but the /members site requires login. I have that part setup exactly the same as another web app which currently works. From: [email protected] [mailto:[email protected]] On Behalf Of Paul Noone Sent: Monday, 7 December 2009 3:25 PM To: ozMOSS Subject: RE: Help! - webclient.downloadData Hi Trent, Just playing with anonymous access now for our public sites. I could be wrong but.I believe that if you're trying to allow access to content on a site requiring authentication then you will still need to allow anonymous access "Lists and Libraries" for the site collection. .which probably means having to do it at the web app level first. From: [email protected] [mailto:[email protected]] On Behalf Of Trent Allday Sent: Monday, 7 December 2009 3:13 PM To: [email protected] Subject: Help! - webclient.downloadData Hi All, I am becoming frustrated after spending too much on this simple issue, hope you can help. I have the following code to download images stored in a sharepoint document library behind a windows authenticated site. Protected Function downloadImage(ByVal imageUrl As String) Dim filename As String = String.Empty Try Dim fileReader As New WebClient() fileReader.Credentials = New Net.NetworkCredential(WsUserName, WsPassword,wsDomain) filename = imageUrl.Substring(imageUrl.LastIndexOf("/") + 1) Return fileReader.DownloadData(imageUrl) Catch ex As Exception HttpContext.Current.Response.Write(ex.Message +"<BR>"+ ex.stacktrace+" <BR>" +filename) Return Nothing End Try End Function Used like this: <img src='http://siteUrl.com/_layouts/imgResize.aspx?image=http://siteUrl.com/mem bers/PublishingImages/bball.jpg&size=80'> Error: The remote server returned an error: (401) Unauthorized. at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadData(Uri address) at imgResize.downloadImage(String imageUrl) bball.jpg Buffer cannot be null. Parameter name: buffer The creditials are public variables and are 100% correct. I have other web apps on this server using the same code (_layouts folder) and works without a problem. The impersonating user is a site collection admin. If I go to the image url I am asked to authenticate as expected, if I pass in the credentials I am using in the code then the image displayed. I thought maybe it was an iis config issue but I have compared web.configs with another working site that implements this code also but it didn't seem to be missing anything. Can anybody shed some light on this. Regards, Trent Allday No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.426 / Virus Database: 270.14.95/2547 - Release Date: 12/06/09 19:37:00 No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.426 / Virus Database: 270.14.95/2547 - Release Date: 12/09/09 19:41:00
_______________________________________________ ozmoss mailing list [email protected] http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss
