Accessing a asmx service from windows-forms gives

2019-06-09 11:50发布

问题:

I try to upload a file using asmx service from windows forms. I have specified max request length in web.config where asmx service is hosted. The service works well when i try to upload a file from a web form where asmx service is hosted.

Now the issue is when i try to upload a file using windows forms it gives me max request length error.

The code of app.config of windows application is as:

<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>

I increase the size of maxbufeerlenth etc but it does not work.

The file i am trying to upload is of size 7 MB only

For smaller files (of less than 1 MB) there is no problem.

One more point i want to add is i add a service in windows forms as a "ADD SERVICE REFERENCE WIZARD".

Any help is appreciated.

回答1:

This is an issue with IIS configuration for Request Limits

this Q&A Add row using jquery helps you

and this is http://www.iis.net/ConfigReference/system.webServer/security/requestFiltering/requestLimits where you find more detailed information