Forum Moderators: open

Message Too Old, No Replies

webclient download problem

webclient remote server error 401

         

ang_bain

10:51 am on Jan 25, 2010 (gmt 0)

10+ Year Member



Hi..i keep getting a remote server error 401 when i try to automate a download from a site using basic authentication..if i do it manually everything works as expected..ie i browse to the url AND I type the username and password into the windows authentication popup that appears and i can then download the file...However when i try to do this through code i just get "remote server returned an error (401) unauthorised...system.net.webexception...i've tried lots of variations using NetworkCredentials to pass the username,password that people have suggested online but so far they all lead to the same error...has anyone come accross this before...

thanks

ps. i'm using vb.net

marcel

2:52 pm on Jan 25, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried Network.DownloadFile?

My.Computer.Network.DownloadFile("http://example.com/download.pdf", "c:\temp\", "userName", "password")

ang_bain

3:22 pm on Jan 25, 2010 (gmt 0)

10+ Year Member



thanks Marcel...i think this is working...its running now...i've never come accross this method...will it work on a server..

thanks
ang

marcel

3:32 pm on Jan 25, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



..will it work on a server..

Yes, as long as the Network Service user has sufficient rights to the download folder.

ang_bain

3:35 pm on Jan 25, 2010 (gmt 0)

10+ Year Member



fab...