C# ASP.NET MVC如何在视图文件夹中注册资源文件,以用作@using

C# ASP.NET MVC如何在视图文件夹中注册资源文件,以用作@using,c#,asp.net-mvc,C#,Asp.net Mvc,在我的视图中,我希望引用放置在我的视图文件夹中的资源文件 我已尝试在视图标题中设置此选项: @using SolutionName.Areas.Main.Views 但intellisense仅显示控制器和模型 SolutionName.Areas.Main.Controller SolutionName.Areas.Main.Model 如何将视图文件夹也列出?只需将名称空间纳入范围: @using MyResources = SolutionName.Areas.Main.Views

在我的视图中,我希望引用放置在我的视图文件夹中的资源文件

我已尝试在视图标题中设置此选项:

@using SolutionName.Areas.Main.Views
但intellisense仅显示控制器和模型

SolutionName.Areas.Main.Controller
SolutionName.Areas.Main.Model

如何将视图文件夹也列出?

只需将名称空间纳入范围:

@using MyResources = SolutionName.Areas.Main.Views
然后,每当您想使用该资源文件时,您只需编写以下内容:

@MyResources.String1
有关更多信息:-

更新:-

并设置属性,如下图所示:-


您确定您的资源文件位于
SolutionName.Areas.Main.Views
命名空间下吗?我在您提供的url中找到了我要查找的信息。谢谢通过在resx属性中将CustomTool设置为PublicResXFileCodeGenerator。我最初设置为ResXFileCodeGenerator。我很高兴它对您有所帮助,我也相应地更新了我的ans@Kman