2015-11-25 198 views
0

當我上傳文件小於64kb然後工作正常,但是當我嘗試上傳文件多於100 kb然後它不起作用。我不知道如何設置wcf web配置文件。我花了更多的時間來解決這個問題,但我沒有找到任何適當的解決方案。在我的網頁配置中是否有任何錯誤?如何使用wcf服務上傳文件(大小超過1 mb)

我的WCF服務名稱是:TestServices.Service1.svc

請在下面的文件網絡配置文件:

<?xml version="1.0"?> 
<configuration> 

    <connectionStrings> 
    <add name="TestEntities" connectionString="metadata=res://*/IHSDataModel.csdl|res://*/IHSDataModel.ssdl|res://*/IHSDataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=S01;initial catalog=TestDb;persist security info=True;user id=sa;[email protected];MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/> 
    </connectionStrings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5" maxRequestLength="2147483647"/> 
    </system.web> 
    <system.serviceModel>  
    <behaviors> 
     <serviceBehaviors> 
     <behavior>   
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https" /> 
    </protocolMapping> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    <directoryBrowse enabled="true"/> 
    </system.webServer> 
    <system.serviceModel> 
    <diagnostics> 
     <messageLogging 
      logEntireMessage="true" 
      logMalformedMessages="false" 
      logMessagesAtServiceLevel="true" 
      logMessagesAtTransportLevel="false"/> 
    </diagnostics> 
    </system.serviceModel> 
</configuration> 

回答

0

您需要在web.config中添加requestlimit標記。所以,舉個例子:

<location path="Documents/Upload"> 
    <system.web> 
    <!-- 50MB in kilobytes, default is 4096 or 4MB--> 
    <httpRuntime maxRequestLength="51200" /> 
    </system.web> 
    <system.webServer> 
    <security> 
     <requestFiltering> 
     <!-- 50MB in bytes, default is 30000000 or approx. 28.6102 Mb--> 
     <requestLimits maxAllowedContentLength="52428800" /> 
     </requestFiltering> 
    </security> 
    </system.webServer> 
</location> 
+0

感謝您的回覆。 – Hitesh

相關問題