c# - Uploading file to Web API timeouts on the server -
i've been having problem day, , i'm pretty lost why happens.
i'm posting file (a .xls file) client side in react js component in response click on button this:
upload: function (e) { e.preventdefault(); var model = this.state.model; var xlsfile = this.refs.xlsfile.getdomnode(); var file = xlsfile.files[0]; var fd = new formdata(); fd.append('file', file); var request = { groupid: this.state.vknumber, payload: fd }; model.importrequest = request; model.setimportprocessing(); multiorderactions.updateusers(request); this.setstate(model.tostate()); }
the request appears in chrome (post-request):
accept:/ accept-encoding:gzip, deflate accept-language:en-us,en;q=0.8,da;q=0.6 connection:keep-alive content-length:3799243 content-type:multipart/form-data; boundary=----webkitformboundarybvyydsxrza1yruw4
and payload of request:
------webkitformboundarybvyydsxrza1yruw4 content-disposition: form-data; name="file"; filename="bruger_caas.xls" content-type: application/vnd.ms-excel
------webkitformboundarybvyydsxrza1yruw4--
should there not binary data in request? content length correct, , content-type , filename.
in webapi i'm doing following, readasmultipartasync never returns:
[httppost] [route("bc/s/{*url}")] public async task<ihttpactionresult> post(string url) { var service = createclient<genericservice>(); if (request.content.ismimemultipartcontent()) { try { var provider = new multipartmemorystreamprovider(); await request.content.readasmultipartasync(provider); foreach (var content in provider.contents) { //do stuff ; } } catch (exception e) { ; } } return internalservererror(); }
when reaches await keyword dies, , times out after 2 minutes, because chrome cancels request.
what doing wrong here? i'm not sure if problem file never sent client side, or if it's server side code that's problem.
any input appreciated.
Comments
Post a Comment