Solved

Uploading saved files in asp.net

Posted on 2013-01-16
4
229 Views
Last Modified: 2013-02-28
Hi experts!

I'm trying to upload a saved pdf file to webserver but the server is returning an error 404: not found. The IIS 7 is running on my machine where I'm administrador and the folder App has permittion to Everybody (full). I try too include ASPNET user on folder security. For the download process everything works fine but for upload the error appears.

The partial code:

WebClient WebClient = new WebClient();
WebClient.Credentials = CredentialCache.DefaultNetworkCredentials;

string LocalFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "File1.pdf");

WebClient.DownloadFile("http://localhost/App/File1.pdf", LocalFile); /* it works fine */
WebClient.UploadFile("http://localhost/App/File2.pdf", LocalFile); /* it not works */

Any suggestions?
Thanks in advance!
0
Comment
Question by:ZumbaJr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 21

Expert Comment

by:masterpass
ID: 38784503
I think you are referring to the filename in here

WebClient.UploadFile("http://localhost/App/File2.pdf", LocalFile); /* it not works */

try like this :

WebClient.UploadFile("http://localhost/App", LocalFile);

Hope this helps :)
0
 
LVL 8

Expert Comment

by:deepu chandran
ID: 38785968
Have a look at this article,looks like useful for you

http://www.codeproject.com/Articles/8600/UploadFileEx-C-s-WebClient-UploadFile-with-more-fu 

--Deepu
0
 

Author Comment

by:ZumbaJr
ID: 38787140
Hi folks!

The questions that I didn't understood yet is: the UploadFile FileName must be in application machine, not client machine. When I run DownloadFile it downloaded too the application machine. In my case, the same machine, here is the confusion. When I run the application from other host, the files still remains in application machine and when I run UploadFile method with filename paths on the application machine it works. But I'm looking for a method that upload files from Client Machine to Application Machine without use file form field to do it, only indicating the local path.

Thanks very much!
0
 
LVL 21

Accepted Solution

by:
masterpass earned 500 total points
ID: 38788772
I did not quite get your question but once the application goes to production, you are most likely to have an address say www.xyz.com which is going to static and so the webclient should work just fine.

alternatively, you can look at fileupload control which uploads files from client machine to server : http://www.codeproject.com/Articles/1757/File-Upload-with-ASP-NET

hope this helps :)
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question