How to return a JSON object in standard web forms .Net

前端 未结 3 1243
逝去的感伤
逝去的感伤 2020-11-30 01:07

The objective is to call a method which does it\'s thing then returns a JSON object.

I\'m new to JSON.

I have a default.aspx and in it the following code. No

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 02:03

    Been a while since I worked with webforms, but if remember correctly it should work if you put the webmethod attribute over GetFile method and make that method static.

     [WebMethod]
     public static string GetFile(string day)
    

    Furthermore, how you post data in ajax method is a bit off. Remove querystring day from url and data should be in json format, something like {"day":day}

提交回复
热议问题