title: How to return a JSON object in standard web forms .Net
body: <p>The objective is to call a method which does it's thing then returns a JSON object.</p>
  
  <p>I'm new to JSON.</p>
  
  <p>I have a default.aspx and in it the following code. Now I want an ordinary method in Default.aspx.cs to run on the click event here.</p>
  
  <pre><code>$(".day").click(function (event) {
  var day = $(event.currentTarget).attr('id');
  if (day != "") {
      $.ajax(
      {
          type: "POST",
          async: true,
          url: 'Default.aspx?day=' + day,
          data: day,
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function (msg) {
              console.log("SUCCESS:" + msg);
              //  $(".stripp img").attr('src', "data:image/jpg;" + msg);
              //  $(".stripp").show();
          },
          error: function (msg) {
              console.log("error:" + msg);
          }
      });
  }
  </code></pre>
  
  <p>});</p>
  
  <p>Default.aspx.cs looks similar to this:</p>
  
  <pre><code>    protected void Page_Load(object sender, EventArgs e)
      {
          if (Request.QueryString["day"] != null)
              GetFile(Request.QueryString["day"]);
      }
      public string GetFile(string day)
      {
          string json = "";
          byte[] bytes = getByteArray();
  
          json = JsonConvert.SerializeObject(bytes);
          return json;
      }
  </code></pre>
  
  <p>Where am I going wrong here?
  Should I be using this in some way or is it only applicable in Web Services?</p>
  
  <pre><code>    [WebMethod]
      [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
  </code></pre>