当我执行以下行来搭建剃须刀页面时:
dotnet aspnet-codegenerator razorpage -m EncryptTextModel -udl -outDir Pages\EncryptTextModel --referenceScriptLibraries
我得到这个输出:
Building project ...
Finding the generator 'razorpage'...
Running the generator 'razorpage'...
Please provide a valid dataContext
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
RunTime 00:00:06.71
此页面不会将数据持久化到数据库,因此它不需要 dataContext - 它只是加密文本。如何让 ASP.NET 在没有数据上下文的情况下为该页面搭建基架?
我目前正在使用 Visual Studio 2017。我使用本教程作为我的指南。