Debugging ASP.NET Core Projects

To run and debug ASP.NET Core projects, you need to have the .NET Core runtime installed. You can typically check if .NET Core is installed by running the dotnet command in Terminal/Command Prompt.

The IDEs will automatically find the installed .NET Core runtime in its default location. The following topics will help you set up .NET Core, if needed.

Launching

Fire and Water provide extra support to assist especially with ASP.NET Core debugging.

When launching your project, the IDE looks for a file called launchSettings.json and uses its content for determining the best course of action for launching.

In particular, it will look at several values from the first "profile" entry with a commandName of "Project". The environment variables specified in this json block will be passed to the debugged process, in addition to those specified in the Environment Variables Manager.

One or more application URLs can be specified (as semicolon-separted list), and they will also be passed to the process, and determine on which ports and under which protocols the web server will launch. Note that running the server as secure HTTPS might need some additional setup in the project, see Enforce HTTPS in ASP.NET Core in Microsoft's documentation for .NET Core.

On first launch, Fire or Water will also automatically offer to launch the URL provided in launchUrl in the default browser, if the launchBrowser setting is true. If launchUrl is a relative path, it will be appended to the first URL in applicationUrl.

On subsequent restarts (within the same IDE session), this will be skipped, to avoid opening many redundant browser tabs or windows.

 "profiles": {
    ...,
    "WebApplication1": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "weatherforecast",
      "applicationUrl": "https://localhost:5000;http://localhost:5001",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }

Note that in addition to the above steps, the debugger is hardwired to always provide the ASPNETCORE_ENVIRONMENT=Development environment variable, whether provided in launchSettings.json or not.

Debugging

Once your your ASP.NET Core application is launched, you can debug your code the same as you would any other project. For example, you can set Breakpoints to pause execution when a certain part of your code is hit, and you will automatically "break" into the debugger, if any Exception occurs.

Note that as a server project, ASP.NET Core projects run headless, and provide no direct user interface (aside from informational messages in the Debug Console. You will test your application by interacting with it from a web browser window, or a separate client application that would make requests to it.

See Also