0

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);
John Saunders
  • 160,644
  • 26
  • 247
  • 397
Tawani
  • 11,067
  • 20
  • 82
  • 106
  • Please show some of the service code. Please say what version of .NET. Is this a WCF or ASMX service and/or client? Is this a web site or a web application project? – John Saunders Aug 05 '09 at 14:01

1 Answers1

1

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
  • 10,593
  • 10
  • 63
  • 87