Skip to content

Web App Template

jennyf19 edited this page Jul 18, 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 template

Blazor web app (Microsoft identity platform, Single Org)

mkdir blazorserver
cd blazorserver
dotnet new blazorserver2 --auth SingleOrg

Blazor web app (Microsoft identity platform, Multiple Orgs)

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

Blazor Web app Azure AD B2C

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

Web Blazor app calling Microsoft Graph

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

Web Blazor 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"

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