【发布时间】:2021-08-09 18:10:20
【问题描述】:
在 Razor 页面项目中,我必须覆盖 ASP.NET 标识的默认 UI。除了特定的页面要求之外,我不想要像“/Identity/Account/Whatever”这样的网址 - 我的页面将是 /login、/logout 等。
但是我仍然想将身份验证页面分组到一个子文件夹中(不要污染顶部文件夹),而是从“根”URL 提供它们。
...
Pages
/Auth
Login.cshtml -> /login
Logout.cshtml -> /logout
ResetPassword.cshtml -> /resetpassword
...
Index.cshtml
Privacy.cshtml
...
目前为了实现这一点,我的 Startup.cs 中有以下代码
services.AddRazorPages(options =>
{
options.Conventions.AddPageRoute("/Auth/Login", "login");
options.Conventions.AddPageRoute("/Auth/Logout", "logout");
options.Conventions.AddPageRoute("/Auth/ResetPassword", "resetpassword");
...
});
Can this be achieved with folder convention? Also I don't want to have /auth/{page} URLs still working (which is a problem with the current approach).
【问题讨论】:
-
嗨@Georg,关于这个案例有什么更新吗?
标签: asp.net-core razor-pages asp.net-core-razor-pages