2015-11-25 222 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

相关问题