找不到类型或命名空间名称 'IWebHostEnvironment'(是否缺少 using 指令或程序集引用?)
The type or namespace name 'IWebHostEnvironment' could not be found (are you missing a using directive or an assembly reference?)
我正在使用 .NET Core 3.0.100; Microsoft Visual Studio Community 2019 Preview Version 16.4.0 Preview 1.0 ; Blazor-server(正式版).
我正在尝试将身份验证和授权添加到我的 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)
然后我右击项目,选择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 Class 库 Microsoft.AspNetCore.Identity.UI (3.0.0)
中,我无法编辑它。
如何解决?
这是一个问题,
生成的代码是
Microsoft.AspNetCore.Hosting
@using Microsoft.AspNetCore.Mvc.ViewEngines
@inject IWebHostEnvironment Environment
@inject ICompositeViewEngine Engine
它不见了@using
应该是
@using Microsoft.AspNetCore.Hosting
报告了问题
通过添加我们的 csproj 文件(3.1 核心应用程序)解决了问题:
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
我正在使用 .NET Core 3.0.100; Microsoft Visual Studio Community 2019 Preview Version 16.4.0 Preview 1.0 ; Blazor-server(正式版).
我正在尝试将身份验证和授权添加到我的 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)
然后我右击项目,选择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 Class 库 Microsoft.AspNetCore.Identity.UI (3.0.0)
中,我无法编辑它。
如何解决?
这是一个问题,
生成的代码是
Microsoft.AspNetCore.Hosting
@using Microsoft.AspNetCore.Mvc.ViewEngines
@inject IWebHostEnvironment Environment
@inject ICompositeViewEngine Engine
它不见了@using
应该是
@using Microsoft.AspNetCore.Hosting
报告了问题
通过添加我们的 csproj 文件(3.1 核心应用程序)解决了问题:
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>