背景
我的 Asp.Net Core 3.1 网站中有一个名为 SignupAndApply 的剃刀页面。它实际上是注册身份页面的复制和粘贴,但是:
- 有一些附加字段
- 允许可选的 applyid 作为路由的一部分传递
- 如果我传递 applyId 作为路由的一部分,我会对页面进行一些标签更改并将用户重定向到其他地方
我想为此页面创建两条路线:
/identity/account/signupandapply/{applyId?} 'when the user is applying and signing up
/identity/account/signup 'when the user is just signing up
我已将以下内容添加到页面顶部:
@page "{applyId?}"
并将 applyId 设置为 OnGetAsync 方法上的可选参数:
public async Task OnGetAsync(string returnUrl = null, Guid? applyId = null)
Issue
带有 applyId 的路由有效,但 /identity/account/signup 路由无效。
我尝试将其添加到我的启动中:
services.AddMvc()
.AddRazorPagesOptions(options => options.Conventions
.AddPageRoute("/identity/account/signupandapply", "/identity/account/signup")
);
如果我去其中之一就可以了
/identity/account/signupandapply/<fooapplyid>
/identity/account/signupandapply
但不是这个
/identity/account/signup
有什么想法我做错了什么应该添加一个简单的替代路线吗?
这一页(/identity/account/signupandapply
) 位于区域内Identity
,所以你需要使用AddAreaPageRoute
代替AddAreaPage
:
services.AddRazorPages().AddRazorPagesOptions(options =>
{
options.Conventions.AddAreaPageRoute("Identity",
"/account/signupandapply", "identity/account/signup");
}); ;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)