How to debug a CSP page
I'm trying to debug a CSP page but I'm not able to set up a breakpoint into <script> tag.
Is it possible to setup on CSP files? Am I forgeting something?
PS:
this is the tag
<script language="Cache" method="OnPreHTTP" arguments="" returntype="%Boolean">
Hi David,
you can actually debug a csp page with the studio debugger. However, this requires a bit more preparation, as you need to identify the csp server process running your page, which is not always straightforward.
An easier approach would be to use the command line debugger in combination with the CSP shell.
In this example I am setting the breakpoint to
and then request the menu page within the CSP shell:
This drops us into the regular command line debugger.
I hope this helps.
-Fab
Another option is to use Serenji
Here is some information about debugging CSP pages using Studio. I actually just taught this to students in class yesterday!
1. You can't set a breakpoint inside the ObjectScript on a CSP page (inside a <script> tag). But the workaround for this is to use the View > View Other Code and load the class definition that's generated from the CSP page. Then you can set breakpoints normally.
2. Once you've set breakpoints, you can set your CSP page as the Debugging Target, and launch it directly from Studio. The page runs in a special "debug mode". This means that the normal timeouts (typically 60 seconds) are suspended, so that the browser and the CSP Gateway will wait as long as necessary while you step through the code.
You can step through the code that is called when the page is first being built, and you can also step through code that is called via a hyperevent.
The only issue with stepping through the code is that Studio does not seem to be highlighting the current line as it normally does. I think this used to work fine, so I may bring this up with the developers. But a workaround for now is to use the "Call Stack" tab of the Watch Window. The top line of the call stack shows the label+offset of the current line. As you step, the top line is updated with the current label+offset. You can simply click the top line whenever you want and the Code Window will scroll to that line, also showing you the current values of the variables.
Hi Joel,
I know this is an old post, but it applies to something I am doing now. My question is, when you mention "and launch it directly from Studio." How is this accomplished?
Thank you,
Patrick
See documentation: Frequently Asked Questions About CSP: How do I debug a CSP page?