0
asp.net(webフォーム)のc#コードビハインドページには、同じページのajax呼び出しから呼び出すWebメソッドがあります。ajaxコールからdebug c#webmethod?
ajax POSTコールの後に一般的な「内部サーバーエラーが発生しました」が表示されます。
何が起きているのかを判断するためにウェブメソッドコードをステップ実行したいと思います。
どうすればいいですか?ブレークポイントはヒットしません。私が付けなければならないプロセスはありますか? WebMethod呼び出しを処理するローカルIISで実行されているプロセスに関する情報が見つかりませんか?
注:Page_Load
などの通常のイベント応答機能をデバッグして実行することができます。
Ajaxコード:
$.ajax({
type: "POST",
url: "/Patrol/Report.aspx/GetSPResults",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify(postData)
}).done(function (result) {
var results = "";
if (result.d.length > 0) {
results = JSON.parse(result.d);
}
buildViewModel(results);
kendo.bind($("#Report"), viewModel);
$("Checkpoints").fadeIn(100);
}).fail(function (jqXHR, textStatus, err) {
alert("An error has occurred: " + err);
});
ウェブ方法:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string GetSPResults(string reportId, string sproc, Dictionary<string, string> parameters, string[] ensureArrays)
{
Int32 intReportId;
Console.WriteLine("Report.aspx/GetSPResults called");
if (Int32.TryParse(reportId, out intReportId))
{
AV.Data.SqlSPHelper avdata = new AV.Data.SqlSPHelper(ConfigurationManager.ConnectionStrings["ProductionConnectionString"].ConnectionString);
Dictionary<string, string> sprocCheckParams = new Dictionary<string, string>()
{
{"Sproc", sproc},
{"ReportID", reportId}
};
XElement sprocCheck = avdata.ExecuteSPXmlXElement("[dw].[spReport_Sproc_Check]", sprocCheckParams, null);
if (sprocCheck.GetAttributeVal("result") == "1")
{
XElement result = avdata.ExecuteSPXmlXElement(sproc, parameters, null);
result = result?.RemoveAllNamespacesAndNils();
if (result != null)
{
var jsonResults = JsonConvertWrapper.SerializeXelement(result, ensureArrays, true, Formatting.Indented, true);
return jsonResults;
}
}
}
return string.Empty;
}
を期待引数名
reportID
は、このコードに関連付けられた '.aspx'ファイルがある持っていましたか..?もしそうなら、 '.cs'ファイルを指し示す' CodeBehind'プロパティがあります。.aspxページのヘッダーを表示できますか? – MethodMan@MethodMan私はあなたのためにこれを行うことができますが、 'Page_Load'のような通常のイベント関数の上でコードを実行することができます。これはあなたの理論を暴露しますか? –
おそらくいくつかのページエラーが発生しています..あなたが投稿したコードに基づいて何が起こっているかを伝えることは本当に難しいです。 – MethodMan