Ajax GET requests to an ASP.NET Page Method?

后端 未结 2 543
孤独总比滥情好
孤独总比滥情好 2020-12-15 09:43

A situation I ran across this week: we have a jQuery Ajax call that goes back to the server to get data

$.ajax(
{
    type: \"POST\",
    contentType: \"appl         


        
相关标签:
2条回答
  • 2020-12-15 10:22

    For security reasons, ASP.Net AJAX page methods only support POST requests.

    0 讨论(0)
  • 2020-12-15 10:39

    It is true that ASP.NET AJAX page methods only support POST requests for security reasons but you can override this behavior by decorating your WebMethod with this these both attribute:

    [WebMethod]
    [ScriptMethod(UseHttpGet = true)]
    

    I felt that the accepted answer was incomplete without pointing out a work around.

    0 讨论(0)
提交回复
热议问题