VS 2017 ASP.NET Core Web应用程序和个人用户帐户有效,但页面不存在 [英] VS 2017 ASP.NET Core Web Application and Individual User Accounts works but pages are non-existent

查看:176
本文介绍了VS 2017 ASP.NET Core Web应用程序和个人用户帐户有效,但页面不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用"ASP.NET Core Web应用程序"/"Web应用程序"(非MVC)/个人用户帐户"创建Web项目时,我得到了带有注册和登录按钮的示例项目,这些按钮显示了它们当我单击它们时,它们各自的页面.但是...非常奇怪的是,如果我在注册页面上搜索创建新帐户",则找不到...而且更多...在身份区域或任何地方都没有AccountController ...所以1)这些页面不在我的解决方案文件夹中的任何位置,并且2)这些页面在世界上怎么显示?!我已经在两台不同的计算机上尝试过. (使用Core 2.1)

When I create a web project using "ASP.NET Core Web Application" / "Web Application" (non-MVC) / "Individual User Accounts"... I get the sample project with Register and Login buttons that show their respective pages when I click on them. HOWEVER... the very weird thing is if I search for "Create a new account" which is on the register page it's not found... and more... there is no AccountController in the Identity area or anywhere... so 1) the pages aren't anywhere in my solution folder and 2) how in the world are these pages showing up?!? I've tried on two different computers now. (using Core 2.1)

作为示例,此链接有效:

As an example this link works:

<a asp-area="Identity" asp-page="/Account/Login">Login</a>

带我去:

https://localhost:44300/Identity/Account/Login

,但是我的文件夹结构(在解决方案中和在磁盘上)都像这样:

and yet my folder structure (both in the solution and on disk) looks like this:

推荐答案

带有身份的ASP.NET Core 2.1自动包含默认UI".这是一个Razor Pages类库,通过Startup中的AddDefaultIdentity进行了引用,在后台它实际上称为AddDefaultUI.

ASP.NET Core 2.1 with Identity automatically includes the "Default UI". It's a Razor Pages class library that's referenced via AddDefaultIdentity in Startup, which under the hood literally calls AddDefaultUI.

如果要在项目中使用实际文件,则需要将它们放入支架中.在解决方案资源管理器中右键单击您的项目,然后选择添加">新的支架项目...",然后单击左侧的标识"列表,然后添加按钮.将弹出一个新窗口,允许您选择要包含的页面,上下文等.对其进行配置,以自己喜欢和喜欢的方式进行.

If you want the actual files in your project, you need to scaffold them in. Right click your project in the solution explorer and choose Add > New Scaffolded Item... Then, click the Identity listing on the left, and then the Add button. A new window will pop allowing you to select the pages you want included, your context, etc. Configure it how you like and go.

还值得注意的是,只要您使用AddDefaultIdentity,仍然会包含默认UI,这意味着您实际上不需要所有需要的脚手架文件.它们本质上将用作替代.将使用项目中明确包含的所有内容,而缺少的所有内容将从默认UI中提取.

It's also worth noting, that as long as you use AddDefaultIdentity, the default UI is still included, which means you don't actually need all the scaffolded files if you want any of them. They'll essentially function as overrides. Anything specifically included in your project will be used, while anything that's missing will be pulled from the default UI.

这还意味着,如果要执行诸如使用标准控制器操作和视图(而不是剃刀"页面)之类的操作,则默认UI将保持 still 的状态并处于优先地位.如果要完全关闭默认UI,则必须使用AddIdentityAddIdentityCore而不是AddDefaultIdentity.

This also means that if you want to do something like use standard controller actions and views instead of Razor Pages, the default UI will still be active, and take precedence. You have to use AddIdentity or AddIdentityCore instead of AddDefaultIdentity if you want the default UI off completely.

这篇关于VS 2017 ASP.NET Core Web应用程序和个人用户帐户有效,但页面不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆