Skip to content

Web App Template

Jean-Marc Prieur edited this page Jul 29, 2020 · 41 revisions

Download or build the NuGet package containing the .NET Core template:

You can download the Microsoft.Identity.Web.ProjectTemplates-0.2.0-preview NuGet package from NuGet.org

alternatively if you want to build it yourself clone the Microsoft.Identity.Web repo, and then

cd ProjectTemplates
dotnet pack

Install the templates in dotnet core

cd bin
cd Debug
dotnet new -i Microsoft.Identity.Web.ProjectTemplates.0.2.0-preview.nupkg

Use the Web app MVC template

Web MVC app (Microsoft identity platform, Single Org)

mkdir mvcwebapp
cd mvcwebapp
dotnet new mvc2 --auth SingleOrg

Web MVC app (Microsoft identity platform, Multiple Orgs)

mkdir mvcwebapp-multi-org
cd mvcwebapp-multi-org
dotnet new mvc2 --auth MultiOrg

Web MVC app (Azure AD B2C)

mkdir mvcwebapp-b2c
cd mvcwebapp-b2c
dotnet new mvc2 --auth  IndividualB2C

Web MVC app calling Microsoft Graph

mkdir mvcwebapp-graph
cd mvcwebapp-graph
dotnet new mvc2 --auth  SingleOrg --calls-graph

Web MVC app calling a web API

mkdir mvcwebapp-calls-api
cd mvcwebapp-calls-api
dotnet new mvc2 --auth  SingleOrg --called-api-url "https://localhost:12345" --called-api-scopes "api://{someguid}/access_as_user"

Use the Web app Razor template

Razor Web app (Microsoft identity platform, Single Org)

mkdir webapp
cd webapp
dotnet new webapp2 --auth SingleOrg

Razor Web app (Microsoft identity platform, Multiple Orgs)"

mkdir webapp-multi-org
cd webapp-multi-org
dotnet new webapp2 --auth MultiOrg

Razor Web app Azure AD B2C

mkdir webapp-b2c
cd webapp-b2c
dotnet new webapp2 --auth  IndividualB2C

Web Blazor app calling Microsoft Graph

mkdir webapp-graph
cd webapp-graph
dotnet new webapp2 --auth  SingleOrg --calls-graph

Web Blazor app calling a web API

mkdir webapp-calls-api
cd webapp-calls-api
dotnet new webapp2--auth  SingleOrg --called-api-url "https://localhost:12345" --called-api-scopes "api://{someguid}/access_as_user"

Use the Web app Blazor server template

Blazor server web app (Microsoft identity platform, Single Org)

mkdir blazorserver
cd blazorserver
dotnet new blazorserver2 --auth SingleOrg

Blazor server web app (Microsoft identity platform, Multiple Orgs)

mkdir blazorserver-multi-org
cd blazorserver-multi-org
dotnet new blazorserver2 --auth MultiOrg

Blazor server Web app Azure AD B2C

mkdir blazorserver-b2c
cd blazorserver-b2c
dotnet new blazorserver2 --auth IndividualB2C

Blazor server web app calling Microsoft Graph

```Shell
mkdir blazorserver-graph
cd blazorserver-graph
dotnet new blazorserver2 --auth  SingleOrg --calls-graph

Blazor server web app calling a web API

mkdir blazorserver2 -calls-api
cd blazorserver2 -calls-api
dotnet new blazorserver2 --auth  SingleOrg --called-api-url "https://localhost:12345" --called-api-scopes "api://{someguid}/access_as_user"

Use of the Blazor web assembly template

Blazor web assembly - single-org

mkdir blazorwasm2-singleorg
cd blazorwasm2-singleorg
dotnet new blazorwasm2 --auth SingleOrg

Blazor web assembly single-org, calling Microsoft graph"

mkdir blazorwasm2-singleorg-callsgraph
cd blazorwasm2-singleorg-callsgraph
dotnet new blazorwasm2 --auth SingleOrg --calls-graph

Blazor web assembly single-org, calling a downstream web API"

mkdir blazorwasm2-singleorg-callswebapi
cd blazorwasm2-singleorg-callswebapi
dotnet new blazorwasm2 --auth SingleOrg --called-api-url "https://graph.microsoft.com/beta/me" --called-api-scopes "user.read"

Blazor web assembly, single-org, with hosted Blazor web server web API

mkdir blazorwasm2-singleorg-hosted
cd blazorwasm2-singleorg-hosted
dotnet new blazorwasm2 --auth SingleOrg  --hosted

Blazor web assembly, single-org, with hosted Blazor web server web API calling microsoft graph"

mkdir blazorwasm2-singleorg-callsgraph-hosted
cd blazorwasm2-singleorg-callsgraph-hosted
dotnet new blazorwasm2 --auth SingleOrg --calls-graph --hosted

Blazor web assembly, single-org, with hosted Blazor web server web API calling a downstream web api

mkdir blazorwasm2-singleorg-callswebapi-hosted
cd blazorwasm2-singleorg-callswebapi-hosted
dotnet new blazorwasm2 --auth SingleOrg --called-api-url "https://graph.microsoft.com/beta/me" --called-api-scopes "user.read" --hosted

Blazor web assembly, B2C

mkdir blazorwasm2-b2c
cd blazorwasm2-b2c
dotnet new blazorwasm2 --auth IndividualB2C

Blazor web assembly, B2C, with hosted Blazor web server B2C web API

mkdir blazorwasm2-b2c-hosted
cd blazorwasm2-b2c-hosted
dotnet new blazorwasm2 --auth IndividualB2C  --hosted

Example of a fully configured B2C Razor Web app

  1. Create the app

    dotnet new webapp2 --auth IndividualB2C --aad-b2c-instance "https://fabrikamb2c.b2clogin.com" --client-id "90c0fe63-bcf2-44d5-8fb7-b8bbc0b29dc6" --domain "fabrikamb2c.onmicrosoft.com" --susi-policy-id "b2c_1_susi" --reset-password-policy-id "b2c_1_reset" --edit-profile-policy-id "b2c_1_edit_profile"  
  2. In the launchSettings.json, change the sslPort to 44316

  3. run the Web app: dotnet run

  4. navigate to https://localhost:44316 and sign-in to the application

(optional) Uninstall the templates

Navigate back to ProjectTemplates\bin\Debug and run:

dotnet new -u Microsoft.Identity.Web.ProjectTemplates

Getting started with Microsoft Identity Web

Token cache serialization

Web apps

Web APIs

Daemon scenario

Advanced topics

FAQ

News

Contribute

Other resources

Clone this wiki locally