从windows-forms访问asmx服务会导致最大请求长度错误

本文关键字:请求 错误 访问 windows-forms asmx 服务 | 更新日期: 2023-09-27 18:12:16

我尝试从windows窗体使用asmx服务上传文件。我在web中指定了最大请求长度。配置托管asmx服务的位置。当我尝试从托管asmx服务的web表单上传文件时,该服务工作得很好。

现在的问题是,当我尝试使用windows表单上传文件时,它会给我最大请求长度错误。

windows应用程序的app.config代码如下:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="MySiteServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
                receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false"
                bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="655360000" maxBufferPoolSize="5242880000" maxReceivedMessageSize="655360000"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="81920000" maxArrayLength="163840000"
                    maxBytesPerRead="40960000" maxNameTableCharCount="163840000" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://mysite2.mydomain.com/mysiteservice.asmx"
            binding="basicHttpBinding" bindingConfiguration="MySiteServiceSoap"
            contract="MySiteService.MySiteServiceSoap" name="MySiteServiceSoap" />
    </client>
</system.serviceModel>

我增加了maxbufeerlength等的大小,但它不起作用

我要上传的文件大小只有7 MB

对于较小的文件(小于1mb)没有问题。

还有一点我想补充的是,我在windows窗体中添加一个服务作为"添加服务引用向导"。

从windows-forms访问asmx服务会导致最大请求长度错误

这是IIS配置请求限制的问题

这个Q&A使用jquery帮助你添加行

这是http://www.iis.net/ConfigReference/system.webServer/security/requestFiltering/requestLimits在这里你可以找到更详细的信息