2

For some weird reason, I can't debug the code inside my static web method. The code itself is like this:

public partial class StoredProcedures : BasePage//Inherits from  System.Web.UI.Page
{
  ...........................
  [WebMethod(EnableSession = true)]
    public static object ProcedureList(int jtStartIndex, int jtPageSize, string jtSorting)
    {
        if (jtStartIndex == null)
            jtStartIndex = 0;
        if (jtPageSize == null)
            jtPageSize = 0;
        if (string.IsNullOrEmpty(jtSorting))
            jtSorting = null;
        //Get data from database
        string sql = "select object_name as Name, status as Status, created as Created from user_objects where object_type = 'PROCEDURE'";
        DataTable ds = RequestSingleton.DBConnection.GetDataTable(sql);
        int procCount = ds.Rows.Count;
        if (procCount != 0)
        {
            DataFiller<StoredProc> dtfStoredProc = new DataFiller<StoredProc>();
            List<StoredProc> list = null;
            list = dtfStoredProc.FromDataTableToList(ds);
      .........................
      .............................. 

The JQuery calls the static method, and if I insert breakpoints inside the static method, they are not used. It's probably something obvious that I'm missing, but seems kinda weird that i can't debug the webmethod. The thing is that I want to see what is going on in there, since something is not right, and without debugging, it's kinda hard. Inserting breakpoints in any other place in the ASP.NET project is not a problem, but in that code block, it is.

MPelletier
  • 16,256
  • 15
  • 86
  • 137
Cosmo D
  • 845
  • 4
  • 11
  • 21
  • 1
    Are you able to debug a normal page load? Is it only the JQuery webservice calls which aren't workign? – Kenneth Ito Jan 05 '12 at 16:53
  • Yes, page load and other methods which weren't called by JQuery were debugged as normal, without any issues. – Cosmo D Jan 08 '12 at 07:26

3 Answers3

4

I have found why the static method couldn't be debugged: the value of trace in the web.config file must be set to true, otherwise the breakpoints are not invoked. So to anyone who might have this problem when debugging static webmethods in ASP.NET, check that trace is set to true. It doesn't matter whether the pageOutput is false or true, but trace has to be set to true. Thanks for your time and answers.

Cosmo D
  • 845
  • 4
  • 11
  • 21
0

Make sure that you have the ASP.NET debugger enabled by going to the properties of the web project. Choose the Web tab and in the bottom of that page you have a couple of different options for what debuggers you want to enable.

Also ensure if you have multiple projects that you have attached the debugger, if not you can go to Tools-> Attach to Process and choose the WebDev.WebServer40.exe process and attach to it.

Mharlin
  • 1,697
  • 16
  • 24
0

use Debugger.Break in first line, it will pop up message box asking to attach debugger when hit

Brijesh Mishra
  • 2,738
  • 1
  • 21
  • 36