note: I gave up on the webclient class and used Vick Soulios’ VB FTP class on GotDotNet. It hangs for a few seconds when it’s making the connection, but the upload works like a charm. Thanks Vick! But if someone can explain WHY the webclient.UploadFile was failing – translation …what was I doing wrong…I’d love to know and share the answer.
I have been having some fun with the WebClient.UploadFile method for the last few days. My IIS Admin is joining in as well. According to the docs, this is the non asp.net way to emulate the HTMLInput file posting methodology. One advantage you have in asp.net is that if you are posting the file to the same domain, then it’s easy enough to set the proper permissions to let this happen. However, when you are trying to do this from outside of the domain, it ain’t so easy. IIS doesn’t see a referral page, so it blocks the request. The only suggestion I have found anywhere is to bag the UploadFile and go with TCPClient and a network Stream. Sure I can do that if I have to, but then what’s the purpose of the UploadFile? When I am setting the proper credentials using my ftp login and password, I can’t see how this is any different than using a standard FTP app such as WS_FTP.
Another thing I have found in my queries is a number of people trying to upload files to web services. Someone always asks – “why on earth do you want to upload a file to a web service?” Now I know the answer! Because the web service will have all of the same authentication that the asp.net app does.
But I will figure out how to use the WebClient.UploadFile because now I’m determined to make it work and I’ll definitely share the solution here.
If anyone was wondering what ever happened to BLInk!, my tablet blogging app, this (and work and some damned fine skiing snow) has been part of the holdup.
Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!