Ajax对webservice的调用失败

时间:2011-10-27 16:19:19

标签: jquery asp.net web-services

我有一个ajax调用 http://mydomain.com/ClientServices/RewardsService.asmx / DisableDivAppsAreNotSupported

会抛出以下错误:

<span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>

<h2> <i>Request format is unrecognized for URL unexpectedly ending in '/DisableDivAppsAreNotSupported'.</i> </h2></span>

<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

<b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

<br><br>

<b> Exception Details: </b>System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/DisableDivAppsAreNotSupported'.<br><br>

<b>Source Error:</b> <br><br>

<table width=100% bgcolor="#ffffcc">
   <tr>
      <td>
          <code>

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code>

      </td>
   </tr>
</table>

<br>

为什么它不识别url末尾的op?

1 个答案:

答案 0 :(得分:3)

您的网址不正确。尝试:

http://mydomain.com/ClientServices/RewardsService.asmx/DisableDivAppsAreNotSupported

要检查的其他一些事项:

  • 确保已启用脚本服务 [System.Web.Script.Services.ScriptService]

  • 确保网络期待JSON [ScriptMethod(ResponseFormat=ResponseFormat.Json)]

  • 确保getpost已启用:

<configuration>
    <system.web>
    <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
    </system.web>
</configuration>