AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

Setting IdentityUIFrameworkVersion>Bootstrap4</IdentityUIFrameworkVersion

Open alexisconsuegra opened this issue 3 years ago • 19 comments

First suggested method: Adding <IdentityUIFrameworkVersion>Bootstrap4</IdentityUIFrameworkVersion> to PropertyGroup did not solved the problem. Is there anything missing in this aproach? Migrating to Boostrap 5 is not possible at this time. Thanks


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

alexisconsuegra avatar Aug 11 '22 01:08 alexisconsuegra

@haok or @Rick-Anderson Can you help with this issue?

gewarren avatar Aug 11 '22 20:08 gewarren

First suggested method: Adding Bootstrap4 to PropertyGroup did not solved the problem.

Can you create the simplest possible repo that demonstrates this problem? Create a RP o MV app with individual user accounts using the 5.0 templates. Add

<PropertyGroup>
  <TargetFramework>net6.0</TargetFramework>
  <IdentityUIFrameworkVersion>Bootstrap4</IdentityUIFrameworkVersion>
</PropertyGroup>

Rick-Anderson avatar Aug 11 '22 21:08 Rick-Anderson

Also did you scaffold out any/all of the identity UI pages?

HaoK avatar Aug 11 '22 22:08 HaoK

Hi, The article did not mention the need to scaffold out any/all of the identity UI pages, did it? Can you elaborate here? But in my case this was a NET 5 project. The identity UI pages were scaffolded using the 5 templates (That's why the Boostrap version is 4). On top of that all the UI pages have been worked on to show a real app looked. Re-scaffolding them means recreating the pages again.

alexisconsuegra avatar Aug 12 '22 02:08 alexisconsuegra

After setting the property to boostrap4, can you double check via F12 on one of your identity pages, after forcing a reload of all the resources, that the bootstrap assets you are getting from identity ui are bootstrap 5 or 4?

HaoK avatar Aug 12 '22 02:08 HaoK

Hi Haok, The application does not start: Unhandled exception. Here is the error. System.InvalidOperationException: Found an invalid value for the 'IdentityUIFrameworkVersion'. Valid values are 'Bootstrap4', 'Bootstrap3' at Microsoft.AspNetCore.Identity.IdentityBuilderUIExtensions.TryResolveUIFramework(Assembly assembly, UIFramework& uiFramework) at Microsoft.AspNetCore.Identity.IdentityBuilderUIExtensions.<>c__DisplayClass2_0.<AddRelatedParts>b__0(ApplicationPartManager partManager) at Microsoft.Extensions.DependencyInjection.MvcCoreMvcBuilderExtensions.ConfigureApplicationPartManager(IMvcBuilder builder, Action`1 setupAction)

alexisconsuegra avatar Aug 12 '22 02:08 alexisconsuegra

Here is the project file used to build it:

`<Project Sdk="Microsoft.NET.Sdk.Web">

net6.0 Bootstrap4 aspnet-MyTest-x...x all runtime; build; native; contentfiles; analyzers; buildtransitive `

alexisconsuegra avatar Aug 12 '22 02:08 alexisconsuegra

<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>net6.0 </TargetFramework> <IdentityUIFrameworkVersion>Bootstrap4 </IdentityUIFrameworkVersion> <UserSecretsId>aspnet-MyTest-x...x </UserSecretsId> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="6.0.7" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.7" /> <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.7" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.7" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.7" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.7"> <PrivateAssets>all </PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive </IncludeAssets> </PackageReference> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.7" /> </ItemGroup> <ItemGroup> <Folder Include="Extensions\" /> </ItemGroup> </Project>

alexisconsuegra avatar Aug 12 '22 02:08 alexisconsuegra

That error message seems to point at the problem, are you sure you are running against 6.0? It should only support Bootstrap5 and Bootstrap4

HaoK avatar Aug 12 '22 02:08 HaoK

That said, we only guarantee this works against the non scaffolded identity UI, if you replaced/scaffolded pages, you should be able to directly update your links in your pages, and point back to boostrap4 on any pages you scaffolded out

HaoK avatar Aug 12 '22 02:08 HaoK

Hi Haok, In regards to your first question: Wouldn't the following line guarantee it is running against 6.0? <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>net6.0 </TargetFramework> Second questions. I will try to answer: The identity UI pages were originally scaffolded using the core 5 templates. I updated the target framework and packages to version 6. UI pages were not re-scaffolded again. I hope this helps understand.

alexisconsuegra avatar Aug 16 '22 03:08 alexisconsuegra

Can you create a repro project and upload it to a git so I can see the behavior for myself and investigate?

HaoK avatar Aug 16 '22 04:08 HaoK

Can you create a repro project and upload it to a git so I can see the behavior for myself and investigate?

Create the simplest possible project.

Rick-Anderson avatar Aug 16 '22 05:08 Rick-Anderson

Hi Yes, let me have a simple project. FYI. It works in my local host, but it throws the error at my hosted enviroment. I have confirmed core 6 is installed.

alexisconsuegra avatar Aug 16 '22 22:08 alexisconsuegra

Hi. This is the simple repo with @alexisconsuegra 's issue: https://github.com/bcons009/netcore-demo5

bcons009 avatar Aug 24 '22 22:08 bcons009

Hi @Rick-Anderson Have you been able to check the repo Bryan created for this issue?

alexisconsuegra avatar Aug 29 '22 22:08 alexisconsuegra

@alexisconsuegra I create an ASP.NET Core MVC project with individual user accounts using .NET 5, then I updated the project settings with the following:

	<PropertyGroup>
		<TargetFramework>net6.0</TargetFramework>
		<IdentityUIFrameworkVersion>Bootstrap4</IdentityUIFrameworkVersion>
		<UserSecretsId>aspnet-WebApplication1-66EF50D6-BDA8-4633-8B19-2CB038E9DA15</UserSecretsId>
	</PropertyGroup>

And it worked as expected. F12 tools shows it's using Bootstrap4

Rick-Anderson avatar Aug 29 '22 22:08 Rick-Anderson

I guess the work around only works in localhost. FYI. Locally works for me too, but not in the hosted enviroment.

alexisconsuegra avatar Aug 30 '22 02:08 alexisconsuegra

https://webbootstrap44.azurewebsites.net/ Works fine deployed too.

Rick-Anderson avatar Aug 30 '22 03:08 Rick-Anderson