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 

 

_______________________________________________
ozmoss mailing list
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

Reply via email to