0

2 つの webmethods を持つ単純な webservice があります。

https://localhost/Sub/WS/Dash.asmx/test_error_methodnameXXXXXXXXXXX

ブラウザから上記のリクエストを呼び出すと。次のようなエラーメッセージが表示されます:-

System.InvalidOperationException: test_error_methodnameXXXXXXXXXXX Web サービス メソッド名が無効です。 System.Web.Services.Protocols.HttpServerProtocol.Initialize() で System.Web.Services.Protocols.ServerProtocolFactory.Create (型の種類、HttpContext コンテキスト、HttpRequest 要求、HttpResponse 応答、Boolean & abortProcessing)

次のようにweb.configファイルを使用して回避しようとしました:-

<system.web>    
    <customErrors mode="On" defaultRedirect="~/Sub/ErrorPage/AppErrors.aspx">
       <error statusCode="500" redirect="500.aspx" />
    </customErrors>       
</system.web>

この場合、リダイレクトは500.aspx ページまたは AppErrors.aspx に対して行われません。モード属性の値を変更すると、変更が行われていることがわかります..

ありがとう。

4

2 に答える 2

1

web.configの助けを借りて修正を見つけました。

<diagnostics suppressReturningExceptions="true"/>  
于 2012-09-05T07:35:11.390 に答える
0

JavaScript の Web メソッドを呼び出すには、Web サービスをスクリプト サービスとしてマークする必要があります。

[ScriptService]
public class MyService : WebService
{

}

それへの参照をスクリプト マネージャーに含めます。

<asp:ScriptManager ID="_scriptManager" runat="server">
  <Services>
    <asp:ServiceReference Path="Dash.asmx" />
  </Services>
</asp:ScriptManager>

jsで呼び出す

try {
    Dash.MyService.ErrorMethodName();
}
catch(exception){
    //handle exception
}
finally {
    //round up
}
于 2012-08-28T08:07:26.150 に答える