**Web Config:**
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1" />
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<!--Add refernce to any new service that is to be added
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true">
<serviceActivations>
<add relativeAddress="EmployeeService.svc" service="PeopleInbox.ServiceLibrary.EmployeeService" />
<add relativeAddress="LookupService.svc" service="PeopleInbox.ServiceLibrary.LookupService" />
<add relativeAddress="SecurityService.svc" service="PeopleInbox.ServiceLibrary.SecurityService" />
<add relativeAddress="EmployerService.svc" service="PeopleInbox.ServiceLibrary.EmployerService" />
</serviceActivations>
</serviceHostingEnvironment>-->
<services>
<service name="PeopleInbox.ServiceLibrary.EmployeeService">
<endpoint address="" binding="basicHttpBinding" contract="PeopleInbox.ServiceLibrary.IEmployeeService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/PeopleInbox.ServiceLibrary/EmployeeService/" />
</baseAddresses>
</host>
</service>
<service name="PeopleInbox.ServiceLibrary.AdminService">
<endpoint address="" binding="basicHttpBinding" contract="PeopleInbox.ServiceLibrary.IAdminService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/PeopleInbox.ServiceLibrary/AdminService/" />
</baseAddresses>
</host>
</service>
<service name="PeopleInbox.ServiceLibrary.LookupService">
<endpoint address="" binding="basicHttpBinding" contract="PeopleInbox.ServiceLibrary.ILookupService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/PeopleInbox.ServiceLibrary/LookupService/" />
</baseAddresses>
</host>
</service>
<service name="PeopleInbox.ServiceLibrary.SecurityService">
<endpoint address="" binding="basicHttpBinding" contract="PeopleInbox.ServiceLibrary.ISecurityService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/PeopleInbox.ServiceLibrary/SecurityService/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
错误已超出传入邮件的最大邮件大小配额(65536)。要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性。
请告诉我们在哪里设置maxReceivedMessageSize。我无法创建绑定,也不知道如何使用。我检查了很多教程,但找不到使代码运行的正确答案。谢谢
您需要创建绑定配置并将其分配给服务上的bindingConfiguration
属性。
要创建绑定,请在配置文件的<system.serviceModel>
部分添加一个部分,例如:
<bindings>
<basicHttpBinding>
<binding name="MyHttpBinding"
maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
</bindings>
然后在您的服务端点中,通过bindingConfiguration
元素上的<endpoint>
属性分配上述绑定。例如:
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="MyHttpBinding"
contract="PeopleInbox.ServiceLibrary.IAdminService">
这将导致定义的端点使用您定义的绑定(其中maxReceivedMessageSize
值设置为属性的最大值(Int32.MaxValue),而不是basicHttpBinding
的默认值65536。