Skip to content

OTonGitHub/IS4-BlazorAPI-Demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Notes & Configuration

Project URLs and Ports

- Server:
  • 5550 (https)
  • 5000
- API :
  • 5552 (https)
  • 5002
- Client:
  • 5554 (https)
  • 5004

Running in VSCode

  • ctrl + shift + p in root, .NET: Generate Assets for Build and Debug
  • - Extensions:
    • C# (Omnisharp)
    • XML (Red Hat)

Dotnet Commands

Solution Setup

  • dotnet new web -lang "c# -n "API" -f "net6.0" -o .\API -d -v diag (empty ASP.NET Web Project)
  • dotnet new classlib -lang c# -n DataAccess -f net6.0 -o .\DataAccess -d -v diag (.NET 6 Class Lib)
  • dotnet add API/API.csproj reference DataAccess/DataAccess.csproj
  • dotnet new web -lang "C#" -n "I4Server" -f "net6.0"
  • dotnet sln add .\I4Server\I4Server.csproj
  • dotnet new blazorserver -n "BlazorClient" -f "net6.0" -o .\BlazorClient --auth None
  • dotnet add .\BlazorClient\BlazorClient.csproj reference .\API\API.csproj
  • dotnet sln add .\BlazorClient\BlazorClient.csproj
  • dotnet sln add .\DataAccess\DataAccess.csproj
  • dotnet restore && dotnet clean

Adding Dependencies

- Nuget Gallery .NET CLI:
  • dotnet add API/API.csproj package Microsoft.EntityFrameworkCore.SqlServer
  • dotnet add API/API.csproj package Microsoft.EntityFrameworkCore.Tools
  • dotnet add DataAccess/DataAccess.csproj package Microsoft.EntityFrameworkCore.SqlServer
  • dotnet add DataAccess/DataAccess.csproj package Microsoft.EntityFrameworkCore.Tools
  • - For I4Server project, all packages are registered in the .csproj file, run dotnet restore on them
- Project References:
  • dotnet add API/API.csproj reference DataAccess/DataAccess.csproj
- On fresh build, run dotnet restore, for packages.

EF Core Migrations

  • dotnet new tool-manifest
  • dotnet tool install --local dotnet-ef --version 7.0.5
  • dotnet ef migrations add CreateRestaurantTable --startup-project API/API.csproj --project DataAccess/DataAccess.csproj --context AppDbContext --verbose
  • dotnet ef database update --project DataAccess/DataAccess.csproj -s API/API.csproj
  • dotnet ef migrations add InitialIdentityServer4Migration --project .\I4Server\I4Server.csproj --context PersistedGrantDbContext --verbose
  • dotnet ef migrations add InitialIdentityServer4Migration --project .\I4Server\I4Server.csproj -c configurationDbContext --verbose
  • dotnet ef database update --project .\I4Server\I4Server.csproj -c PersistedGrantDbContext
  • dotnet ef database update --project .\I4Server\I4Server.csproj -c ConfigurationDbContext
  • dotnet ef migrations add InitialAspNetIdentityMigration --project .\I4Server\I4Server.csproj -c AspNetIdentityDbContext
  • dotnet ef database update --project .\I4Server\I4Server.csproj -c AspNetIdentityDbContext

Issues

  • has issue with SQL Server self signed ceritificate, currently uses TrustServerCertificate=True in connection string to override it
  • Unable to set launchUrl in launchSettings.json for either kestrel or IIS, may need to look into WebHostBuilder
  • Need a way to set and forget multiple start up projects for the vscode launcher or global config, instead of using the cli every time
  • Need to update all packages to latest version globally

Notes

  • Even though the IRestaurantService is injected and recognized inside the API controller, the implementation is decided in runtime, in order to register the implementation, configure this in the program.cs by adding builder.services.AddScoped().
  • You have to add this just buefore the builder.build()
  • In the API Controller, default get method does not have to be called by name if route is not mentioned but will be the default when visiting the api/[controller]
  • creating new projects with dotnet new, consider implications of using either --no-https or --no-http as well as the default behaviour.
  • tempkey.jwk is generated in root of I4Server project as development sign in for IS4.

About

Setting up IdentityServer4 with minimal APIs and Blazor Server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published