views:

120

answers:

1

I have a webservice through which I can upload documents to our ASP.NET web site. The problem is when I upload PDF & word documents, they get corrupted when I try to open them. Text documents always upload fine. What is even strange is that on my development machine, these files upload fine but when I try to upload to our demo site, they get corrupted.

Any ideas?

my code is of the format:

WebServicesSoapClient proxy = new WebServicesSoapClient();

byte[] data = GetFileByteStream("C:\\temp\\sample.pdf");
string response = proxy.UploadDocument("james", "password", 
                         orderId, "Sample.pdf", data, true);
+1  A: 

Are your pdf files larger than 4MB? That is the default maximum request length for ASP.NET. You can override that setting in your web.config with:

<httpRuntime maxRequestLength="8192" />

However, be aware that this will increase your memory usage on your server - by default asp.net will cache the entire request in memory.

Also, I'm not entirely certain this is the problem in your case, since normally this exceeding the request length would cause an exception to be thrown - not silent file corruption.

see also http://support.microsoft.com/default.aspx?scid=kb;EN-US;295626

Nathan