且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Ajax调用总是返回错误500客户端

更新时间:2022-06-11 15:07:53

您需要ScriptMethod到您的Web方法,因为你需要发送响应为JSON。

You need to ScriptMethod to your web method because you needs to send the response as json.

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]      
public bool SavePins(string saveData)
{
     try
      {
           File.WriteAllText(string.Format("{0}{1}.shane", file_location, "pinsData"),     saveData);
           return true;
      }
     catch (Exception)
     {
        return false;
      }
 }