title: can't call Response.Redirect inside a static method
body: <p>Hello I'm trying to run a webmethod with ajax from an aspx page. basically I want to redirect to another aspx page with a query string, but I want to do it from <code>&lt;a href&gt;</code>, beacuse it's part of a jquery menu.</p>
  
  <p>from what I learned I can only use ajax to call static webmethods, but I canot redirect from my static function.</p>
  
  <p>visual studio marks it in a red line saying: <strong>"an object reference is required for the nonstatic field method or property System.Web.HttpResponse.Redirect(string)"</strong></p>
  
  <p><strong>here is the ajax call:</strong></p>
  
  <pre><code>function redirect_to_profile() {
      $.ajax({
          type: "POST",
          url: "personal_profile.aspx.cs.aspx/redirect_to_profile",
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function (res) {
             alert("success");
          },
          error: function (res, msg, code) {
              // log the error to the console
          } //error
      });
  }
  </code></pre>
  
  <p><strong>here is the a href:</strong></p>
  
  <pre><code>&lt;a  onclick="redirect_to_profile()"&gt;Personal Profile&lt;/a&gt;
  </code></pre>
  
  <p><strong>here is the webmethod inside the personal_profile.aspx</strong></p>
  
  <pre><code>[WebMethod]
  public static void redirect_to_profile()
  {
  
      dbservices db=new dbservices();
      string user = HttpContext.Current.User.Identity.Name;
      string id = db.return_id_by_user(user);
  
      HttpResponse.Redirect("personal_profile.aspx?id="+id);
  }
  </code></pre>