ajaxgoogle-chrome-devtoolsnancyjquery-bootgridscript-debugging

How do I debug JQuery-BootGrid data api to NancyFX


Question edited:

I wrote a page with jquery-bootgrid data API.

Its should be calling with AJAX to my NancyFX REST API, but it isn't.

  1. Client side:

I'm serving the bootgrid from a local repo:

<script src="~/scripts/jquery.bootgrid.min.js"></script>

Maybe I shouldn't be using the .min.js file but rather the open one for debugging? If so, could you walk me through what to do, or point me in the direction?

The page code is

...
data-toggle="bootgrid" data-ajax="true" 
data-url="/cars/0" data-method="GET"
  1. Server side:

I have the html page served by NancyFx and is seen ok, except for the grid which is empty. There's an API module with a breakpoint in Visual Studio (running on localhost), with the following:

Get["/cars/{status:int}?current={current}&rowCount={rowCount}"] = parameters => ...

This code is never called. How can I force the debugger to catch ANY call before the routing is checked, and show me what's coming into the server?

I'm using the chrome debugger.


Solution

  • The current URL is not valid by Nancy standards. We don't add query string params to the route.

    You would want to write something along the lines of:

    Get["/cars/{status:int}"] = parameters => 
    {
        var status = (int)parameters.status;
        var current = (string)parameters.current.TryParse("");
        var rowCount = (int)parameters.current.TryParse(10);
    
        ...
    }
    

    Along those lines. (written off the top of my head)

    An alternative approach is to bind the request like so:

    Get["/cars/{status:int}"] = parameters => 
    {
        var request = this.Bind<MyRequest>();
    
        ...
    }
    
    public class MyRequest
    {
        public MyRequest()
        {
            RowCount = 10;
        }
    
        public int Status {get;set;}
        public string Current {get;set;}
        public int RowCount {get;set;}
    }