2012-04-01 49 views
11

我需要更改我的web.config文件並在 我的web.config中添加MaxReceivedMessageSize屬性 - 但是哪裏?將MaxReceivedMessageSize屬性放在WCF服務的web.config文件中的位置?

傳入消息的最大消息大小配額(65536)已被超出。要增加配額,請在適當的綁定元素上使用MaxReceivedMessageSize屬性。

<?xml version="1.0"?> 
    <configuration> 
     <system.web> 
     <compilation debug="false"><assemblies><add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /></assemblies></compilation> 
     </system.web> 
     <system.serviceModel> 
     <behaviors> 
      <serviceBehaviors> 
      <behavior> 
       <serviceMetadata httpGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="false" /> 
      </behavior> 
      </serviceBehaviors> 
     </behaviors> 
     <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
     </system.serviceModel> 
    <system.webServer> 
     <modules runAllManagedModulesForAllRequests="true" /> 
     </system.webServer> 
+0

通常,它在綁定元素上設置。雖然你的web.config顯示沒有任何WCF服務的跡象 – 2012-04-01 18:34:41

+0

@DmitriyReznik:最有可能的一個.NET 4 WCF服務,帶有方便的「默認」端點 – 2012-04-01 18:39:50

回答

28

您需要定義要使用,然後你需要定義(在客戶端),你的服務(在服務器端)和客戶端綁定綁定配置爲使用綁定和綁定配置:

<system.serviceModel> 
    <bindings> 
     <!-- pick whichever binding you want .... --> 
     <basicHttpBinding> 
     <!-- binding configuration with a name --> 
     <binding name="ExtendedMaxSize" 
      maxBufferSize="999999" maxReceivedMessageSize="999999" /> 
     </basicHttpBinding> 
    </bindings> 
    <services> 
    <service name="Yournamespace.YourServiceClass" behaviorConfiguration="..."> 
     <!-- define endpoint with your binding and the name of the binding configuration 
      that you have defined just above --> 
     <endpoint address="" 
       binding="basicHttpBinding" 
       bindingConfiguration="ExtendedMaxSize" 
       contract="Yournamespace.IYourServiceContract" /> 
    </service> 
    </services> 
1

幫助那些最終可能會像我一樣的人。 我不能添加到上面的評論(通常有人早在我有問題之前已經有答案),所以我必須添加一個答案。

我有一個MVC 4應用程序,我懷疑上面的初始示例來自實際的WCF服務項目的web.config。其中一條評論提到他們懷疑它是一個MVC 4應用程序和默認配置設置。

但是,您如何解決問題?從更多的研究來看,實際上需要對CLIENT的web.config進行更改,換句話說,該項目的Web配置參考了WCF服務。你會發現在那裏做改變要容易得多。該版本的web.config實際上與您正在尋找的內容相似。

這對我來說很容易,並解決了我的問題。

相關問題