This repository is created for teaching and demonstration purposes. It is meant to help students learn how to work with REST APIs and apply different layers (data layer, business logic layer, and data access layer). The project is incomplete and suffers of several limitations:
- No continuous integration.
- No unit testing.
- Missing end-points / methods.
- No authentication / authorization.
- Missing API documentation.
- Semi-modular.
- Uses .NET CORE 2.2 which is deprecated. Should migrate to .NET CORE 3.X.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Note that the recommended IDE for this project is Visual Studio.
The things you need to install before you proceed with development.
- Visual Studio (2017+) [recommended]: make sure to include the ASP.NET and web development package.
- .NET Core 2.2: install the SDK (required) and the Runtime & Hosting Bundle (optional: if you need to test using IIS instead of IIS Express).
- IIS Express [recommended]: usually it is included with the installation of Visual Studio.
- MySQL Community [required].
A step by step guide to get you started with development.
git clone https://github.com/omaddam/ASP.NET-CORE---REST-API-Sample.git
git flow init
Using one of the following:
-
Command line:
nuget restore "REST API.sln" -
Package Manager Console in Visual Studio:
Update-Package -
Visual Studio rebuild: it automatically restores the packages on rebuild.
Using one of the following:
-
Command line:
dotnet buildFor more information, see dotnet build command.
-
Visual Studio shortcut:
CTRL + SHIFT + B
- Create a new database/schema in MySQL.
- Create a new table
studentswhich has 3 columns:idvarchar(45) / primary keyfirst_namevarchar(45)last_namevarchar(45)
- Update the database connection string.
- For more information on how to construct a connection string, click here.
Use either the command line or Visual Studio.
-
Set the environment variables:
-
Set development mode to display unhandled exceptions in the browser.
SET ASPNETCORE_ENVIRONMENT=Development
-
-
Run:
-
Using the source project:
dotnet run Webservice.csproject -
Using the build: (often found in bin\Debug or bin\Release)
dotnet Webservice.dll
-
-
Set the Webservice project as the startup project.
-
Set the launch profile:
- Open the properties of Webservice project.
- Go to Debug section.
- Select "IIS Express" or "Console" profile.
The list of all available launch profiles can be found in Webservice\Properties\launchSettings.json.
-
Set the webservice project as the startup project.
-
Run the project:
F5