将子文件夹路由到根 URL

问题描述

在 Razor 页面项目中,我必须覆盖 ASP.NET Identity 的认 UI。除了特定的页面要求,我不想要像“/Identity/Account/Whatever”这样的 url - 我的页面将是 /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).

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)