Asp.net WCF服务异常远程服务器返回意外响应:(413)请求实体太大
我有以下wcf服务方法,它接受附件对象,附件类定义为:Asp.net WCF服务异常远程服务器返回意外响应:(413)请求实体太大,asp.net,wcf,.net-4.0,Asp.net,Wcf,.net 4.0,我有以下wcf服务方法,它接受附件对象,附件类定义为: [DataContract] public class Attachment { [DataMember] public int AttachmentId { get; set; } [DataMember] public String DMSFileId { get; set; } [DataMember] public
[DataContract]
public class Attachment
{
[DataMember]
public int AttachmentId { get; set; }
[DataMember]
public String DMSFileId { get; set; }
[DataMember]
public String FileName { get; set; }
[DataMember]
public int? FileSize { get; set; }
[DataMember]
public String FileSource { get; set; }
[DataMember]
public byte[] File { get; set; }
}
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
方法定义为:
[OperationContract]
public int AddAttachment(DataTypes.Administration.Attachment attachment)
{
return AttachmentBusinessLogic.AddAttachment(attachment);
}
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
调用该方法时,我得到以下异常:
远程服务器返回意外响应:413请求实体太大
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
在谷歌上搜索这个错误时,我遇到了许多绑定配置,但没有一个是有效的maxReceivedMessageSize或readerQuotas
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
以下是服务和客户端的web配置:
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
服务
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
客户
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
请就如何克服这一例外提出任何建议 您需要处理的地方是web配置,您需要添加服务行为,以便设置数据的大小。比如说像这样,
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
如果不起作用,请在此处发布您的web配置。希望能有所帮助。我在另一篇文章中按照配置wcf web配置文件的步骤解决了这个问题
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
使用此设置
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<basicHttpBinding>
<binding maxReceivedMessageSize="2147483647" messageEncoding="Text" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" >
<readerQuotas maxStringContentLength="525288"></readerQuotas>
</binding>
</basicHttpBinding>
如果该服务托管在IIS中,那么您在混合中也有IIS的限制。是的,该服务托管在IIS中,我如何配置该服务请注意,我已经尝试了此配置,但它不起作用,可能我缺少一些内容我更新了帖子并添加了web配置。谢谢你的帮助。发布你的服务web.config我已经发布了,我发布了标题为service的服务的web配置。这是什么?这就是您的web配置中的全部内容吗?服务配置和端点配置在哪里?这就是我在服务web配置中的全部内容,我创建了一个新的web应用程序并添加了新的服务。除了我在帖子中提供的内容之外,这里什么都没有,我应该手动添加配置吗?