Skip to content

Getting Started Guide

Sergey Tregub edited this page May 8, 2021 · 6 revisions

Using a command line

  1. Install the template:
dotnet new -i DrWatson1.ProjectTemplate.RestAPI
  1. Create a project:
dotnet new rest-api -n ASPNetCoreService

It creates a new project "ASPNetCoreService" in the corresponding subfolder. Replace the "ASPNetCoreService" with the desired name.

  1. Run the project:
cd ASPNetCoreService
dotnet run
  1. Open a browser and navigate to http://localhost:5000/swagger to see an API documentation
  2. Play around with the API. Try to add a new product or update one

Using Visual Studio

  1. Install the extension from Visual Studio Marketplace or download and install the latest version from GitHub. Also, you can install it from Visual Studio. To do so click on the "Tools/Extensions and Updates..." menu item, then select "Online/Visual Studio Marketplace/Templates" on the left pane, search for "ASP.Net Core RESTful Service Template," select it and click the "Download" button. Please note! The latest version of the template is targeted to the .Net Core 3.1. If you need a template for the 2.x version use one of the previous versions of the template.
  2. Restart Visual Studio
  3. Click on "File/New Project..." menu item
  4. Expand "Installed/Visual C#/.NET Core" on the left pane
  5. Select "APS.Net Core RESTful Service" and click the "OK" button.
  6. Select either "IIS Express" or "ASPNetCore.Sevice1" mode and run a service
  7. Open a browser and navigate to http://localhost:5000/swagger to see an API documentation
  8. Play around with the API. Try to add a new product or update one
  9. By default, the service listens to incoming requests on localhost:5000. If you want to get access to your service from another computer, open appsettings.json and replace the Urls parameter value from http://localhost:5000 to http://*:5000 to listen to all available interfaces. You can use any address or port, of course.

Using .Net 5.0

If you want to use .Net 5.0 instead of .Net Core 3.1 open a .csproj file and change a value of a <TargetFramework> tag from netcoreapp3.1 to net5.0.