title: Calling WebMethods from Business Logic Layer in ASP.Net
body: <p>I am developing an application in ASP.Net using C#. My Application is build in Three Tier Architecture. So there is a Business Logic Layer Exists. I have written am Web Method (named getBusinessVerticals) in a class called Landing_Menus.cs which resides in Business Logic Layer (under App_Code Folder). I have to make an AJAX call to get the results of the function. My Function code is as following (Landing_Menus.cs)</p>
  
  <pre><code>    public static class Landing_Menus
  {
      static string sql_query = string.Empty;
      static DataSet result_ds = new DataSet();
  
      [WebMethod]
      public static Struct_Business_Verticals[] getBusinessVerticals()
      {
          List&lt;Struct_Business_Verticals&gt; list_bv = new List&lt;Struct_Business_Verticals&gt;();
          sql_query = "select * from Business_Verticals";
          result_ds = DBAccess.selectQuery(sql_query);
  
          for (int i = 0; i &lt; result_ds.Tables[0].Rows.Count; i++)
          {
              Struct_Business_Verticals objBusniessVerticals = new Struct_Business_Verticals();
              objBusniessVerticals.Business_Verticals_ID = Convert.ToInt32(result_ds.Tables[0].Rows[i]["Business_Verticals_ID"].ToString());
              objBusniessVerticals.Business_Vertical_Type = result_ds.Tables[0].Rows[i]["Business_Vertical_Type"].ToString();
              objBusniessVerticals.Business_Vertical_Description = result_ds.Tables[0].Rows[i]["Business_Vertical_Description"].ToString();
              objBusniessVerticals.status = result_ds.Tables[0].Rows[i]["Status"].ToString();
              list_bv.Add(objBusniessVerticals);
          }
  
          return list_bv.ToArray();
      }
  }
  </code></pre>
  
  <p>And my AJAX Call Code is as following</p>
  
  <pre><code>    $(document).ready(function () {
      $.ajax({
          type: "POST",
          contentType: "application/json; charset=utf-8",
          url: "App_Code/Landing_Menus.cs/getBusinessVerticals",
          data: "",
          dataType: "JSON",
          async: true,
          cache: false,
          success: function (data) {
              alert(JSON.stringify(data));
              //for (var i = 0; i &lt; data.d.length; i++) {
  
              //}
          },
          error: function (result,d,s) {
              alert(s);
          }
      });
  });
  </code></pre>
  
  <p>But its giving me an error like "NetworkError: 403 Forbidden - <a href="http://www.example.com/web2print/App_Code/Landing_Menus.cs/getBusinessVerticals" rel="nofollow">http://www.example.com/web2print/App_Code/Landing_Menus.cs/getBusinessVerticals</a>". Please help me to get out from here. I think I am doing some mistakes in the AJAX URL. Please guide me accordingly.</p>