简体   繁体   中英

AJAX Call To ASMX Web Service Intermittent Failure

I am investigating a problem calling a web service from AJAX, which intermittently faults with the following error:

Exception information:
Exception type: InvalidOperationException
Exception message: Request format is unrecognized for URL unexpectedly ending in '/GetType'.

This is similar to the following question, but works most of the time - only failing intermittently.

Request format is unrecognized for URL unexpectedly ending in

The UI polls once every couple of seconds, and works fine until some state changes, and then the same calls fail for around 1 minute and 30 seconds, then they continue working.

The POST-ed data is identical in Firebug for a successful call and failed call:

lastResult=''&lastState=33&random=0.7584943767104781

The following configuration applies to the web service

<location path="TypeService.asmx">
    <system.web>
        <webServices>
            <protocols>
                <add name="HttpPost"/>
            </protocols>
        </webServices>
        <authorization>
            <allow users="*"/>
            <allow users="?"/>
        </authorization>
    </system.web>
</location>

I believe the config is correct, as the calls work for long periods. The polling mechanism doesn't change at any point. Is there any other reason for this error message other than the configuration fix that is noted in the other question?

经过进一步研究,我们发现由于服务构造函数中的实际代码错误而导致此错误-因此,这是那些隐藏的错误之一,其中的错误消息并不能真正表明问题所在。

Make sure in jquery ajax call should be like this,

$.ajax({
    type: "GET",
    url: "/ajax.asmx/YOUR_METHOD",
    data: "{}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (msg) { }
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM