2013-05-08 67 views
1

我使用C#將數據發佈到IIS Web服務器中。如何增加Http Post中的項目大小

我已經使用了XML和模式,並且在一個字段中發佈非常長的數據時出現'錯誤的請求錯誤'。 例如,

<Field1>TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT.......<Field1> 

我已經修改我的web.config

<webHttpEndpoint> 
    <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="21474836" maxBufferSize="21474836" maxBufferPoolSize="21474836" ></standardEndpoint> 
      </webHttpEndpoint> 

些什麼,我需要做的,使這項工作?

<system.web> 
     <authentication mode="Forms" /> 
     <compilation debug="true" targetFramework="4.0"> 
      <assemblies> 
       <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
      </assemblies> 
     </compilation> 
     <httpRuntime maxRequestLength="204800" executionTimeout="12000" requestValidationMode="2.0" requestPathInvalidCharacters="" /> 
    </system.web> 
    <system.serviceModel> 
     <serviceHostingEnvironment aspNetCompatibilityEnabled="true"></serviceHostingEnvironment> 
     <standardEndpoints> 
      <webHttpEndpoint> 
       <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="21474836" maxBufferSize="21474836" maxBufferPoolSize="21474836"></standardEndpoint> 
      </webHttpEndpoint> 
     </standardEndpoints> 
    </system.serviceModel> 
+0

如果您使用的JavaScript後回來,然後確保你的web.config設置爲接受大JSON斑點固定它。 [該JSON請求太大,無法反序列化](http://stackoverflow.com/questions/10966328/the-json-request-was-too-large-to-be-deserialized) – Romoku 2013-05-08 19:16:11

+0

我正在使用C#客戶端和XML – DafaDil 2013-05-08 19:17:08

+0

請求正文有多大,請使用Fiddler輕鬆獲取該數字。 – EricLaw 2013-05-08 23:01:05

回答

1

您需要修復在web.config此值的所有請求,而不僅僅是WCF服務,爲你做了...

<httpRuntime maxRequestLength="1234" executionTimeout="1200" /> 

你可能需要增加這個數字。這是首先發生的HttpRuntime - 所有請求都受到此標記定義的規則的約束。您爲WCF服務設置的請求限制將僅在請求首先通過此檢查(及其他)時應用。

+0

我已經更新了web.config文件,如問題所示,它仍然給我那個錯誤。我修改了這個正確的? – DafaDil 2013-05-08 22:00:22

+0

你會收到400:錯誤的請求?這意味着您的請求語法不正確 - 不是長度。請發佈提交您的請求的代碼 - 問題可能在那裏。也看看這個:http://stackoverflow.com/questions/8507853/wcf-rest-4-0-put-post-delete-not-working-400-bad-request?rq=1 – Jasmine 2013-05-08 22:46:43

+0

事情是它在字符串較短時起作用。我現在已經發布了代碼。非常感謝 – DafaDil 2013-05-08 22:52:44

0

我通過添加readerQuotas到standardEndpoint

<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="21474836" maxBufferSize="21474836" maxBufferPoolSize="21474836" > 
      <readerQuotas maxStringContentLength="2048000" maxArrayLength="2048000" maxDepth ="65000"/> 
     </standardEndpoint> 
     </webHttpEndpoint> 
     </standardEndpoints>