为什么 Asp.Net Core 2.1 Identity 使用 Razor Pages?

Why Asp.Net Core 2.1 Identity Use Razor Pages?

我正在开发 .Net 核心身份 Web 应用程序 (MVC),我在名为 Identity 的区域下搭建身份并获取文件夹我不想在我的 MVC 应用程序中使用 Razor 页面,所以是否有任何解决方案可以在我的 MVC 应用程序中搭建身份Controller/View ?并请提及 Microsoft 为什么使用这种方法在 MVC 应用程序中使用剃刀页面的任何好处。

谢谢

this GitHub issue中有解释:

The only current option also seems to be using Razor Pages for the Identity UI. Some of us want full control over how we use Identity so that we can customize it to our needs. The current setup is simply unacceptable. If my entire project is using MVC, I don't want Identity living in its own folder off in la-la land as Razor Pages. It makes the project structure a mess, and there's just no reason for it.

维护同一代码库的两个版本(MVC 和 Razor Pages)对我们来说非常昂贵,与 Razor Pages 版本相比,MVC 实现并没有真正的好处。两种口味都在 ASP.NET 中。将代码移出该区域应该相对简单,并将其从 Razor Pages 转换为 MVC。它可能只是涉及将页面从该区域移动到您的主应用程序页面文件夹并调用 AddIdentity 而不是 AddDefaultIdentity。

Please either fix the options so that those who want it can take full control of Identity and use it as they wish, whether that's the MVC approach or the Razor Pages approach. Or provide us with sufficient documentation so that we may add Identity to a blank project without using the Identity UI library or some magic scaffolding voodoo. As it stands now, there doesn't appear to be any documentation on Identity that doesn't rely on the new scaffolding system and Identity UI.

默认值 UI 是完全可选的。您应该能够将页面构建到您的项目中,然后从那里做任何您想做的事情,无论是将它们转换为 MVC 风格还是将它们移出该区域并进入您的主项目。

总结:这种方法的好处是更容易维护单一版本,同时没有缺点。脚手架 UI 是可选的,您可以自己将其转换为不使用 Razor Pages 的实现,或者您可以从头开始。