1

在 Asp.net core 2 中,他们引入了 razor pages。如果我在解决方案的根目录中创建一个“页面”文件夹,然后添加一个新项目“Greeting.cshtml”,然后在顶部添加一个 @page 指令,然后是我要显示的内容,则使用 Visual Studio 代码,我不当我在运行后导航到http://localhost.whateverport#/Greeting时,什么都看不到。

如果我在 VS17 中做同样的事情,它会起作用。

所以我的问题是,我怎样才能让 Visual Studio 代码检测到这是一个剃须刀页面?

谢谢

4

1 回答 1

1

使用 dotnet new page 命令添加剃须刀页面。例如

dotnet new page -n Index -na MyProject.Pages -o Pages

这将在 pages 文件夹下创建 index.cshtml 和 index.cshtml.cs 文件。

运行帮助命令dotnet new page -h以查看选项。希望这可以帮助。

于 2018-10-25T15:21:19.037 回答