[英]How to do custom routing in asp.net core 2.1 identity ui?
When i am adding route "/Poster/animals_institute/animals_in_trees/research_about_frogs_in_trees" and redirecting to "Dashboard" page using following code then it's working fine. 当我添加路线“ / 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");
});
}
But that's static routing i need to change it with dynamic routes and access these route value in .cs file. 但这是静态路由,我需要使用动态路由进行更改并在.cs文件中访问这些路由值。 Like routes can be following: 类似的路线如下:
/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
How can i do this type of custom routing in asp.net core 2.1 identity ui 我如何在ASP.NET Core 2.1 Identity UI中进行这种类型的自定义路由
Just add route using AddPageRoute method like the following code: 只需使用AddPageRoute方法添加路由,如以下代码所示:
options.Conventions.AddPageRoute("/Game", "/Game/{client}/{event}/{title}"); options.Conventions.AddPageRoute(“ / Game”,“ / Game / {client} / {event} / {title}”);
and you can pass any link like " http://localhost:64643/Game/animals_institute/animals_in_trees/research_about_frogs_in_trees " or " http://localhost:64643//Game/birds_institute/birds_on_trees/research_about_dove " 并且您可以传递任何链接,例如“ 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.