CLI Docs
https://docs.microsoft.com/en-us/dotnet/core/tools/
Install a package
https://github.com/dotnet/docs/blob/main/docs/core/tools/dotnet-add-package.md
dotnet add package Newtonsoft.Json
dotnet add package Hl7.Fhir.R4
dotnet add package Swashbuckle.AspNetCore
dotnet add package System.Net.Http.Json
dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer --version 3.1.21
dotnet add package DotNetEnv
dotnet add package Microsoft.AspNetCore.Authentication.OpenIdConnect
Start app locally
dotent watch
dotnet watch run
Trust Certs
For windows:
dotnet dev-certs https --trust
For linux:
dotnet dev-certs https
sudo -E dotnet dev-certs https -ep /usr/local/share/ca-certificates/aspnet/https.crt --format PEM
New Project
New App List
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-new-list
dotnet new --list
ref: https://dotnet.microsoft.com learn/aspnet/hello-world-tutorial/install
dotnet new webapp -o <dir name> --no-https
Program.cs:
- This is the entrypoint of the app
Catalog.csproj:
- Version of .net we are using
- Packages installed
appsettings.json:
- Like .env file
Controllers:
- ROUTES
File Overview Description
Program.cs contains the app startup code and middleware configuration.
The Pages directory contains some example web pages for the application.
MyWebApp.csproj defines some project settings, such as, .NET SDK version to target.
The launchSettings.json file inside the Properties directory defines different profile settings for the local development environment.
A port number ranging between 5000-5300 is automatically assigned at project creation and saved on this file.
https://coderjony.com/blogs/adding-swagger-to-aspnet-core-31-web-api/
Import into Startup.cs
using Microsoft.OpenApi.Models;
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo {
Title = "My API",
Version = "v1",
Description ="Description for the API goes here.",
Contact = new OpenApiContact
{
Name = "Your Name",
Email = string.Empty,
Url = new Uri("https://google.com/"),
},
});
});
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
// To serve SwaggerUI at application's root page, set the RoutePrefix property to an empty string.
c.RoutePrefix = string.Empty;
});
Change launchUrl to index.html
launchSettings.json
"Micro-Service-Name": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "index.html",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
swagger docs
https://localhost:5001/index.html