![](/img/trans.png)
[英]How to set custom routing for ASP NET CORE Identity 2.1 , extending class libraries
[英]How to do custom routing in asp.net core 2.1 identity ui?
当我添加路线“ / Poster / animals_institute / animals_in_trees / research_about_frogs_in_trees”并使用以下代码重定向到“仪表板”页面时,它工作正常。
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
.AddRazorPagesOptions(options =>
{
options.Conventions.AuthorizePage("/Dashboard");
options.Conventions.AddPageRoute("/Dashboard", "/Game/animals_institute/animals_in_trees/research_about_frogs_in_trees");
});
}
但这是静态路由,我需要使用动态路由进行更改并在.cs文件中访问这些路由值。 类似的路线如下:
/Game/animals_institute/animals_in_trees/research_about_frogs_in_trees
/Game/birds_institute/birds_on_trees/research_about_dove
/Game/animals_institute/know/know_about_cat_in_trees
/Game/animals_institute/show/show_cat_results
/Game/men_institute/men_in_society/know_about_man_in_hospital
我如何在ASP.NET Core 2.1 Identity UI中进行这种类型的自定义路由
只需使用AddPageRoute方法添加路由,如以下代码所示:
options.Conventions.AddPageRoute(“ / Game”,“ / Game / {client} / {event} / {title}”);
并且您可以传递任何链接,例如“ http:// localhost:64643 / Game / animals_institute / animals_in_trees / research_about_frogs_in_trees ”或“ http:// localhost:64643 // Game / birds_institute / birds_on_trees / research_about_dove ”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.