HTTPリクエストがPOSTの場合は、クエリajaxを使用してASP.NETページ内のWebメソッドを呼び出すことができます。 HTTP GET要求が使用されている場合、Webメソッドの代わりにPage_Loadイベントが実行されます。 アイデアJquery、Ajax、およびASP.NET webmethods
は、ここでのAjax
$.ajax({
type: "GET",
url: "http://local.proleaguesports.pagefad.com/AjaxTesting.aspx/receivermethod",
data: "{'test':'MyName'}",
contentType: "application/json",
dataType: "json",
success: mycallback,
error: handler
});
であり、ここであなたが別のWebサービス/ ASMXにあなたのwebMethodsを移動することを検討可能性がある
public partial class AjaxTesting : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Page_Load runs instead of the receivermethod below");
}
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public static string receivermethod()
{
return "test received";
}
}
POSTを使用して –
なぜGetを使用していますか?インターネットで何か読んだら、重大なセキュリティ上の脆弱性が存在することがわかります。 「投稿」しないでしょうか? –
John、良いセキュリティとHTTPGETの記事をお勧めしますか? POSTを使うと思います。しかし今、興味があります:) –