WCF Erholsamen "413 Request Entity Too Large"

Hallo, ich arbeite mit einen WCF Erholsamen services, mit JsonNet, um meine Objekte zu serialisieren
Ich habe haben diese Methode:
Das User-Objekt eine Eigenschaft, die den Typ byte [], wie dies

public class User
{
   public int Id {get;set;}
   public string UserName {get;set}
   public byte[] Photo {get;set;}
}

aber wen ich einen POST mit einem Foto der Größe von mehr als 41 Kb eine bekam den HttpStatusCode "413 Request Entity Too Large"

[WebInvoke(Method = "PUT",
         RequestFormat = WebMessageFormat.Json,
         ResponseFormat = WebMessageFormat.Json,
         BodyStyle = WebMessageBodyStyle.Wrapped,
         UriTemplate = "/user/{id}/")]
        public Stream EditUser(string id, Stream input)
        {
            try
            {
                string json = input.ConvertToString();
                User usr = json.FromJSON<User>();
                usr.Update();

                return null;
            }             
            catch (Exception ex)
            {  
                SetInternalServerErrorResponse();
                return GetResponseError(ex);
            }
        }

dies ist mein webconfig

<bindings>
              <basicHttpBinding>
                  <binding name="" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
                      <readerQuotas maxDepth="35" maxStringContentLength="65536000" maxArrayLength="65536000" maxBytesPerRead="65536000" />
                      <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                  </binding> 
              </basicHttpBinding>
              <webHttpBinding>
                  <binding name="svcBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">               
                      <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                      <security mode="None">
                      </security>
                  </binding>
              </webHttpBinding>
  </bindings>

EDIT: ich finde hier die Lösung:

maxReceivedMessageSize nicht beheben 413: Request Entity Too Large

Die erste Antwort für die post.

Hinzufügen der bindingConfiguration proprety.

  <service  behaviorConfiguration="serviceBehavior" name="Aloes.Services.Service">
     <endpoint  address="" behaviorConfiguration="web"  binding="webHttpBinding" bindingConfiguration="svcBinding"
      contract="Aloes.Services.IService" />
    </service>
InformationsquelleAutor jcmordan | 2014-06-04
Schreibe einen Kommentar