本文介绍了如何检查asp.net的核心方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用个人用户帐户身份验证创建了一个新的ASP.NET Core MVC应用程序.我想看看他们如何实现某些方法.我想可以这样做,因为ASP.NET Core是开源项目,但是在github存储库中找不到这些方法.

I created a new ASP.NET Core MVC application with individual user accounts authentication. I would like to see how they implemented some methods. I suppose I can do it since ASP.NET Core is open source project, but I can't find these methods in github repository.

https://github.com/aspnet/AspNetCore/

我对这种方法非常感兴趣.

I am highly interested in this method.

https://localhost:portnumber/Identity/Account/Login

问题1:如何在我的项目中找到此方法,并且可以对其进行调试?

问题2:为什么在新创建的应用程序中看不到AccountController文件?

答案:事实证明,从.net core 2.2版本开始,如果要查看或更改Identity控制器,则必须手动安装它们.

ANSWER:It turned out, that from .net core 2.2 version if you want to see or change Identity controllers, you have to scaffold them manually.

https://docs.microsoft.com/zh-CN/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-2.2&tabs = visual-studio#scaffold-identity-in-empty-project

推荐答案

您所引用的方法是应用程序的一部分.在 Areas 文件夹下查看.应该有一个名为 Identity 的子文件夹.在Identity文件夹下,您应该找到AccountController,并且Login操作方法应该在此控制器内部.

The methods you are referring to are part of your application. Have a look under the Areas folder. There should be a subfolder called Identity. Under the Identity folder, you should find the AccountController and your Login action method should be inside this controller.

如果您真的想研究源代码,则需要查看 SignInManager.cs 类,并了解如何实现SigninAsync方法,该方法由Login操作方法使用.

If you really want to look into the source code you need to have a look at the SignInManager.cs class and see how the SignInAsync method is implemented, which is used by the Login action method.

编辑

请参考下面的屏幕截图

编辑2

使用Web应用程序模板新建的应用程序的结构

Structure for the newly created app using Web Application template

这篇关于如何检查asp.net的核心方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 21:22