6

I am trying to send large excel file to the rest service ( using servicestack).

client and server(Servicestack service) applications are deployed on different server.

I am using following code at client side to upload the excel file ( 8 mb size)

taken from

http://www.codeproject.com/Articles/501608/Sending-Stream-to-ServiceStack

above code works fine when file to be uploaded is 2-3 MB. it throws the error when file size is large about 8MB.
while debugging it gives me following error

System.Net.WebException was caught
  HResult=-2146233079
  Message=The remote server returned an error: (500) Internal Server Error.
  Source=System
  StackTrace:
       at System.Net.HttpWebRequest.GetResponse()
       at Myproject.Web.Controllers
                  .Employer.FileUploadController
                  .Upload(FileUploadViewModel fileUploadViewModel
        ,HttpPostedFileBase fileUpload
        ,String DataFileType
        ,String UploadedFrom) 
    in d:\MyProject\projNewArch\Controllers\Employer\FileUploadController.cs:line 262
  InnerException:

i have tried changing the setting values which can be seen as connected.

What might be the issue? Please help

Update 1: i have IIS 8.5 at server so i think the file size (8mb) might not be the issue. Do i still need to add the some setting in web.config to allow sending big size file over POST

UPDATE 2 : Found the solution. Adding maxAllowedContentLength and maxRequestLength does the trick. Please check the link provided by Smartdev in comments section

A_m0
  • 974
  • 2
  • 17
  • 45
  • 1
    This link might be relevant: http://stackoverflow.com/questions/2880722/is-http-post-limitless – Ulric Sep 08 '15 at 10:16
  • 1
    ` (500) Internal Server Error` you need to look at the *server* traces, and debug the *server*. – Remus Rusanu Sep 08 '15 at 10:16
  • @ulric I have updated the qustion . do you think that might be the issue? – A_m0 Sep 08 '15 at 10:24
  • 2
    This error is not triggered by your application. This is triggered by the 'remote server'. You should check it and if you have access to it, most probably you need to increase the `maxRequestLength` there. Check this post for more details: http://stackoverflow.com/questions/3853767/maximum-request-length-exceeded. – SmartDev Sep 08 '15 at 10:37
  • @amol - tbh, I am a little out of my depth when it comes to the technical intricacies of IIS. Hopefully someone else will be able to provide a precise answer for you. – Ulric Sep 08 '15 at 10:39
  • @ulric .thanks you very much for help – A_m0 Sep 08 '15 at 10:53
  • @SmartDev : OK .will try that – A_m0 Sep 08 '15 at 10:53
  • adding maxAllowedContentLength and maxRequestLength does the trick. Please check the link provided by smartdev – A_m0 Sep 08 '15 at 12:19

1 Answers1

1

You still need to edit your web.config file. It should look like this:

<system.webServer>
<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="10485760" /> 
  </requestFiltering>
</security>

This will allow you to upload up to 10MB

Yuri
  • 2,820
  • 4
  • 28
  • 40