Solved

HttpPostFile.SaveAs is saving empty file in IIS

Posted on 2012-04-03
2
526 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

948 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now