找不到类型或名称空间名称“ IWebHostEnvironment”(您是否缺少using指令或程序集引用?)


11

我正在使用.NET Core 3.0.100; Microsoft Visual Studio Community 2019预览版本16.4.0预览版1.0; Blazor服务器(官方发行版)。

我正在尝试将身份验证和授权添加到我的Blazor服务器Web应用程序。我在这里阅读指南https://docs.microsoft.com/zh-cn/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-3.0&tabs=visual-studio#scaffold-identity-into-an -空项目

(我也阅读了这个https://github.com/aspnet/Identity/issues/1825

然后,我右键单击Project,选择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

屏幕截图[![在此处输入图片描述] [4]] [4]

因为文件\obj\Debug\netcoreapp3.0\Razor\Pages\Shared\_Layout.cshtml.g.cs位于Razor类库中,Microsoft.AspNetCore.Identity.UI (3.0.0)所以我无法对其进行编辑。

如何解决?



Answers:


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.