-
Notifications
You must be signed in to change notification settings - Fork 24
Getting Started Guide
Sergey Tregub edited this page May 8, 2021
·
6 revisions
- Install the template:
dotnet new -i DrWatson1.ProjectTemplate.RestAPI
- 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.
- Run the project:
cd ASPNetCoreService
dotnet run
- Open a browser and navigate to http://localhost:5000/swagger to see an API documentation
- Play around with the API. Try to add a new product or update one
- 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.
- Restart Visual Studio
- Click on "File/New Project..." menu item
- Expand "Installed/Visual C#/.NET Core" on the left pane
- Select "APS.Net Core RESTful Service" and click the "OK" button.
- Select either "IIS Express" or "ASPNetCore.Sevice1" mode and run a service
- Open a browser and navigate to http://localhost:5000/swagger to see an API documentation
- Play around with the API. Try to add a new product or update one
- By default, the service listens to incoming requests on
localhost:5000. If you want to get access to your service from another computer, openappsettings.jsonand replace theUrlsparameter value fromhttp://localhost:5000tohttp://*:5000to listen to all available interfaces. You can use any address or port, of course.
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.