.NET Core 3.0.100、Microsoft Visual Studio Community 2019 プレビュー バージョン 16.4.0 プレビュー 1.0、Blazor-server (正式リリース) を使用しています。
BlazorサーバーのWebアプリに認証と承認を追加しようとしています。ここでガイドラインを読んでいます。https://learn.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-3.0&tabs=visual-studio#scaffold-identity-into-an-empty-project
(私もこれを読んだhttps://github.com/aspnet/Identity/issues/1825)
次にプロジェクトを右クリックし、Add
\New Scaffolded Item...
ファイルを読んでScaffoldingReadme.txt
、ガイドに従います。
デバッグのために F5 を押すと、エラーが見つかります。
Severity: Error
Error Code: CS0246
Description: The type or namespace name 'IWebHostEnvironment' could not be found (are you missing a using directive or an assembly reference?)
Project: foo
File: C:\Users\donhuvy\Desktop\foo\bar\obj\Debug\netcoreapp3.0\Razor\Pages\Shared\_Layout.cshtml.g.cs
Line: 455
Suppression State: Active
\obj\Debug\netcoreapp3.0\Razor\Pages\Shared\_Layout.cshtml.g.cs
ファイルはRazor クラス ライブラリ内にあるためMicrosoft.AspNetCore.Identity.UI (3.0.0)
、編集できません。
どうすれば修正できますか?
ベストアンサー1
これは問題です。
コード生成は
Microsoft.AspNetCore.Hosting
@using Microsoft.AspNetCore.Mvc.ViewEngines
@inject IWebHostEnvironment Environment
@inject ICompositeViewEngine Engine
欠けている@using
そのはず
@using Microsoft.AspNetCore.Hosting
私は問題を報告しましたhttps://github.com/aspnet/Scaffolding/issues/1094