【问题标题】:Ajax call to webservice fails对 web 服务的 Ajax 调用失败
【发布时间】:2011-10-27 16:19:18
【问题描述】:

我有一个 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?

【问题讨论】:

标签: jquery asp.net web-services


【解决方案1】:

您的网址不正确。试试:

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>

【讨论】:

  • 我的错,ajax 调用“../DisableDivAppsAreNotSupported”并收到此错误。脚本服务已启用。我想返回 void,而不是 Json。还有其他想法吗?
  • 发布你的 JS/jQuery 和你的服务定义(至少是方法的签名)。另外,请参阅编辑 - 您是否检查过您的获取和发布协议?
猜你喜欢
  • 2010-10-29
  • 1970-01-01
  • 2012-08-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多