2011-10-27 81 views
3

我有一個AJAX調用 http://mydomain.com/ClientServices/RewardsService.asmx/DisableDivAppsAreNotSupportedAjax調用Web服務失敗

這引發以下錯誤:

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

爲什麼它不承認在運的結束網址是什麼?

+1

見[這個問題](http://stackoverflow.com/questions/654099/how-do-i-fix-a-request-format-is-unrecognized-for-url-error -in-a-web-sevic) – GregL

+1

你的服務是如何定義的? – jrummell

回答

3

你的URL不正確。嘗試:

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

我的不好,ajax調用「../DisableDivAppsAreNotSupported」並得到這個錯誤。腳本服務已啓用。我想返回void,而不是Json。任何其他想法? –

+0

發佈你的JS/jQuery和你的服務定義(至少是方法的簽名)。另外,請參閱編輯 - 你有沒有檢查你的協議? –