Microsoft-identity-web: [Bug] 'IMvcBuilder' does not contain a definition for 'AddMicrosoftIdentityUI'

Created on 24 Nov 2020  路  2Comments  路  Source: AzureAD/microsoft-identity-web

Which version of Microsoft Identity Web are you using?
1.3.0

Where is the issue?

  • Web app

    • [X] Sign-in users

    • [ ] Sign-in users and call web APIs

  • Web API

    • [ ] Protected web APIs (validating tokens)

    • [ ] Protected web APIs (validating scopes)

    • [ ] Protected web APIs call downstream web APIs

  • Token cache serialization

    • [ ] In-memory caches

    • [ ] Session caches

    • [ ] Distributed caches

  • Other (please describe)

Is this a new or an existing app?
The app is in production and I have just installed Microsoft.Identity.Web for the first time.

Repro
The AddMicrosoftIdentityUI method should work on IMvcBuilder according to the documentation. Yet in the most recent release of Microsoft.Identity.Web, that doesn't seem to be the case. See below.

image

Expected behavior
I expected the method call to work and help me produce the UI needed in order to integrate with Azure AD.

Actual behavior
When calling AddMicrosoftIdentityUI immediately after AddMvc, I get the following error message:

'IMvcBuilder' does not contain a definition for 'AddMicrosoftIdentityUI' and no accessible extension method 'AddMicrosoftIdentityUI' accepting a first argument of type 'IMvcBuilder' could be found (are you missing a using directive or an assembly reference?)

I get this error despite having added using Microsoft.Identity.Web; to the beginning of my Startup.cs file.

Additional context / logs / screenshots
My app is targeting net5.0 and is using the Microsoft.NET.Sdk.Web SDK.

I added the following package reference to my csproj file:

<PackageReference Include="Microsoft.Identity.Web" Version="1.3.0" />

The other method calls (e.g., AddMicrosoftIdentityWebAppAuthentication) seem to be working as expected.

Has this method call changed since the release of 1.3.0?

Answered question

Most helpful comment

image

All 2 comments

@sebastianbk , you need to add a reference to Microsoft.Identity.Web.UI.

BTW if you use .NET 5.0, the ASP.NET core templates use Microsoft.Identity.Web, and therefore you'll get ready to use apps.
(dotnet new webapp --auth SingleOrg, or dotnet new mvc --auth SingleOrg)

See also https://github.com/AzureAD/microsoft-identity-web/wiki/web-app-template if you use .NET Core 3.1 and that lists all the possibilities (including calling Graph or an API)

image

Was this page helpful?
0 / 5 - 0 ratings