c# - How to increase the file size limit in WCF console application -
i've having simple wcf service (a console application file upload). keep getting error (400) bad request. works when upload small files (4kb) failing 700kb.
from readings i've done stack overflow , other, i'll have increase maxreceivedmessagesize. implemented using custom class , overriding onopening method still didn't work.
i'm testing console application using webclient
outputbytes = webclient.uploaddata(baseurl + "/uploads/2." + filenameonly, file.readallbytes(filename));
also, i'm using webservicehost in
var uri = new uri("http://localhost:8000");
var svc = new webservicehost(typeof (uploadservice), uri);
how solve issue? ps: application not have config file i'll looking @ how set in code. if not , config file needed, should content.
notes: found link bad request error 400 - wcf client explained properties valid soap based services. suggested updating web.config. since console application, i'm wondering how can done'
regards.
you can set maximumreceivedmessage programatically this:
var binding = new wshttpbinding(); // or whatever binding using binding.maxreceivedmessagesize = int32.maxvalue; var wcfclient = new wcfservicetestclient(binding, strserviceurl);
hopefully enough solve problem, might want consider chopping file bits (batching) before sending server. sending large chunks of data can incurr huge memory penalty client has serialize entire thing front before sending server (and same deserialize on server side).
edit: based on additional comment (below), code on application hosting service might this:
webservicehost webservicehost = new webservicehost(typeof(uploadservice), uri); webhttpbinding binding = new webhttpbinding(); binding.maxreceivedmessagesize = int32.maxvalue; webservicehost.addserviceendpoint(typeof(iuploadservice), binding, "webservicehost"); webservicehost.open();
Comments
Post a Comment