0

I have some code like this:

@{
ViewBag.Title = "Home";

var grid = new JqGridHelper<Project>("projects",
dataType: JqGridDataTypes.Json,
methodType: JqGridMethodTypes.Post,
pager: true,
rowsNumber: 10,
sortingName: "Id",
sortingOrder: JqGridSortingOrders.Asc,
subgridEnabled: true, 
url: Url.Action("ProjectsByUser"), <---- Here
etc...

By my understanding, url: URL.Action("FunctionName") will call a function that exists somewhere in my project with the name "FunctionName". All I want to do is look at the variables in the function while its running, but placing a breakpoint in VS doesn't work. So how would I go about doingnspect is executed, but the debugger only shows the code of scripts being executed, not the that? I've tried debugging with Chrome by setting up breakpoints before the code I want to in c# code.

Jimmy T
  • 447
  • 6
  • 14

1 Answers1

0

I'm not sure why placing a breakpoint would not work (assuming you start running the project in the debugger, and the breakpoint is in the right place).

You can add the following code to the method you wish to debug:

#if DEBUG
System.Diagnostics.Debugger.Break();
#endif

That will force a debug break, and prompt to attach a debugger if none is currently attached.

Remember to remove the code after you are done troubleshooting. While the #if DEBUG will prevent that code from being part of a release build, you don't want to risk accidentally shipping a DEBUG build that contains that break instruction.

Eric J.
  • 147,927
  • 63
  • 340
  • 553
  • I tried that and nothing happened. I can place a breakpoint at the line of code which is shown above but because the url.action line is just setting an option for the JqGridHelper function, theres nothing to step into. I'm not sure how the c# code is being called, but breakpoints or your mentioned method doesn't seem to be recognized. Is the c# code even being called? – Jimmy T Dec 09 '13 at 02:21
  • View source of the HTML and see exactly what URL is generated by Url.Action. – Eric J. Dec 09 '13 at 02:26
  • I think this is it: url: '/home/ProjectsByUser'. home is the page that contains the code above, and ProjectsByUser is the function I want to call. – Jimmy T Dec 09 '13 at 02:37
  • How does the program know where to find the function ProjectsByUser? Does this need to be specified anywhere? – Jimmy T Dec 09 '13 at 03:01
  • If this is an ASP.Net MVC project, the URL you indicate would (by default) be routed to the ProjectsByUser method in the HomeController class. – Eric J. Dec 09 '13 at 08:37