Don't you need a return type on the function... a byte array? http://msdn.microsoft.com/en-us/library/xz398a3f(VS.80).aspx
Regards, Paul Turner Senior Solutions Specialist M: 0412 748 168 P: 08 8238 0912 F: 08 8234 5966 A: 66 Henley Beach Road, Mile End SA 5031 E: paul.tur...@dws.com.au<mailto:paul.tur...@dws.com.au> W: www.dws.com.au<https://webmail.dws.com.au/owa/UrlBlockedError.aspx> ADVANCED BUSINESS SOLUTIONS LTD This email and any files transmitted with it are confidential and are only for the use of the person to whom they are addressed. If you are not the intended recipient you have received this email in error and are requested to delete it immediately. Any opinion expressed in this e-mail may not necessarily be that of DWS Pty Ltd. Please consider the environment before printing this email. ________________________________ From: ozmoss-boun...@ozmoss.com [ozmoss-boun...@ozmoss.com] On Behalf Of Trent Allday [tr...@tadsolutions.com.au] Sent: Monday, 7 December 2009 2:43 PM To: ozmoss@ozmoss.com 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/members/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
_______________________________________________ ozmoss mailing list ozmoss@ozmoss.com http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss