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

问题描述 投票:0回答:1

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

我正在尝试将身份验证和授权添加到我的Blazor服务器Web应用程序中。我在这里阅读指南https://docs.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

然后我右键单击Project,选择Add \ New Scaffolded Item...

enter image description here

然后

enter image description here

然后enter image description here

我阅读了文件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:        acc133blazor
File:       C:\Users\donhuvy\Desktop\acc133b3\acc133blazor\obj\Debug\netcoreapp3.0\Razor\Pages\Shared\_Layout.cshtml.g.cs
Line:       455
Suppression State:  Active

截屏enter image description here

这是_Layout.cshtml.g.cs https://gist.github.com/donhuvy/6754843e62cd08c6bf5b2ef8f326b5f1的内容>

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

如何解决?

我正在使用.NET Core 3.0.100; Microsoft Visual Studio Community 2019预览版本16.4.0预览版1.0; Blazor服务器(官方发行版)。我试图将身份验证和授权添加到我的...

asp.net-core blazor asp.net-core-identity .net-core-3.0 asp.net-core-3.0
1个回答
2
投票

这是一个问题,


0
投票

我启动了新项目,并选中了用于身份验证的复选框,它可以正常工作,在创建项目之后稍后将身份验证页面设置为脚手架似乎有此问题。

© www.soinside.com 2019 - 2024. All rights reserved.