Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

Response Status code 400:Bad Request because of posting data with large size (httpclient)

$
0
0

at my project (asp.net soap webservice) I'm sending a form contains a file and a string to a webservice method via httpclient right as below:

using(FileStream fs =File.Open(FileFullPath,FileMode.Open,FileAccess.Read,FileShare.ReadWrite)){using(var client =newHttpClient(newHttpClientHandler{UseProxy=false,Proxy=null})){using(var formData =newMultipartFormDataContent()){
                    client.Timeout=TimeSpan.FromMilliseconds(Timeout.Infinite);//client.MaxResponseContentBufferSize = fs.Length;HttpContentTokenContent=newStringContent(Token);HttpContent fileStreamContent =newStreamContent(fs);

                    formData.Add(TokenContent,"Token");
                    formData.Add(fileStreamContent,Key, currentFile);var response = await client.PostAsync(WebServiceOfServer, formData).ConfigureAwait(false);// equivalent of pressing the submit button on the formif(!response.IsSuccessStatusCode){
                        result =null;}else{
                        result = response.Content.ReadAsStreamAsync().Result;returntrue;}}}}

But in sending files which have the size grearter than 2GB, the response status code is 400 with the BadRequest phrase reason. 
 And In the web.config I used this codes:

<httpRuntimemaxRequestLength="3145728"requestLengthDiskThreshold="3145728"targetFramework="4.5.1"requestValidationMode="2.0"executionTimeout="999999"/>

and

<requestLimitsmaxAllowedContentLength="3221225472"/>

How can I solve my problem?

 

 


Viewing all articles
Browse latest Browse all 555

Trending Articles