Solved

HttpPostFile.SaveAs is saving empty file in IIS

Posted on 2012-04-03
2
527 Views
Last Modified: 2012-04-04
I upload multiple files via an ASP page and save them as HttpPostFiles in a datatable while the user enters data in a form. When the user clicks Save, I write the data to SQL tables and save the HttpPostFiles to a server folder.

This works fine in debug mode in Visual Studio 2010, but not in IIS 7 on my local PC. It does work with only one file in IIS.

The symptom when it fails is that the files get saved to the server folder with 0 bytes, and the code does not save the database record. I suspect it fails, but Console.Write does not record anything in the IIS log file.

Its funny that it works with one file, but when it fails with with multiple files, even the first file in the datatable does not get saved properly.
RequestEdit.aspx.cs
Export-Doc.cs
RequestEdit.aspx
0
Comment
Question by:venture-it
2 Comments
 
LVL 21

Accepted Solution

by:
Craig Wagner earned 500 total points
ID: 37806622
The first problem is your debugging technique. Console.Write() isn't going to go anywhere in a web application. Options that you could use would be to use Debug.Write and then use the debug viewer from SysInternals (http://technet.microsoft.com/en-us/sysinternals/bb896647) to watch the debug output. Another option would be to write to the Windows Event Log. Third would be to remove the try/catch temporarily and let the exception turn into a YSOD in the browser. The way save_Docs and save_New_Docs are currently working you are effectively swallowing any exceptions that occur.
0
 

Author Comment

by:venture-it
ID: 37808407
Thanks, I got the Debug.Write to work with the debug viewer. I will accept this as solution so you get the points,  and will repost when I have more analysis.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 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