1

I can't find any docs on how to add debugging to ASP.NET Core 2.0. Also, what the debugging actually does. I've tried to add the following to my startup.cs but it does not seem to have any affect. My question is for Visual Studio 2017 and running core stand alone.

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc();
        services.AddNodeServices(options => {
            options.LaunchWithDebugging = true;
            options.DebuggingPort = 9229;
        });
    }

1 Answer 1

1

After setting above configuration in ConfigureServices method of startup.cs, run your application using command line e.g. dotnet run. Then from browser visit one of your page that causes server-side JS to execute. Then you should see all the normal trace messages appear in console like this-

warn: Microsoft.AspNetCore.NodeServices[0]
      Debugger listening on port 9229.
warn: Microsoft.AspNetCore.NodeServices[0]
      To start debugging, open the following URL in Chrome:
warn: Microsoft.AspNetCore.NodeServices[0]
          chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

As per instructions in last line, open the URL in Chrome.

By expanding the entry in left hand side under sources tab, you will able to see your original source code (using source maps), and then set breakpoints wherever you want.

When you re-run your app in another browser window, your breakpoints will be hit, then you can debug the server-side execution (similar to client-side).

For more information, refer this link.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.