Create an ASP.NET Core web service

Debug your Service

  1. Open the Controllers/ValuesController.cs class by double-clicking it the Solution pad on the left-hand side of the screen.

  2. This ASP.NET Core project uses the MVC architecture, which follows a standard convention. By default, an API controller like ValuesController will handle all web requests to www.mydomain.com/api/Values and route them to the method matching the rest of the path.

  3. Locate the Get method. This method will handle requests to www.mydomain.com/api/Values/Get. The project is configured by default to process this request, so the /Get may be omitted. Note that there are also methods for Get and Post (both with parameters).

  4. Click the editor margin to the left of the return new string[]… line of code in Get to set a breakpoint. A breakpoint is used to stop execution of the app at that point and debug your app.

    Code screenshot

  5. Click the Start Debugging button (with a Play icon) on the top left to build and start debugging the app. Alternatively, you can also start debugging by selecting the Run -> Start Debugging menu item.

  6. When the application hits the line of code with the breakpoint, it stops executing and you will have access to a full array of debugging tools, including the call stack, variable inspectors, and more.

  7. Click the Continue Running (the new Play icon in the group of 4) button to continue executing the code.

  8. The API response will appear in your browser as JSON.

    Debug screenshot


I ran into an issue I have run my service