您好我的工作丝毫一个WCF的REST类型的服务,用JsonNet连载我的对象我有这个有这样的方法:用户对象有一个属性类型为byte []像这样
public class User
{
public int Id {get;set;}
public string UserName {get;set}
public byte[] Photo {get;set;}
}
但文我做一个POST白衣照片的大小超过41 KB一个拿到HttpStatusCode“413请求实体过大”
[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);
}
}
这是我的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>
编辑:我在这里找到了解决方案:
maxReceivedMessageSize不固定413:请求实体太大
在文章的第一反应。
添加bindingConfiguration proprety。
<service behaviorConfiguration="serviceBehavior" name="Aloes.Services.Service">
<endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="svcBinding"
contract="Aloes.Services.IService" />
</service>