简体   繁体   English

如何在ASP.NET Core 2.1 Identity UI中进行自定义路由?

[英]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.

相关问题 如何为ASP NET CORE Identity 2.1设置自定义路由,扩展类库 - How to set custom routing for ASP NET CORE Identity 2.1 , extending class libraries 如何在 Identity ASP.NET Core 2.1(Identity Scaffolded)中播种用户角色 - How do I seed user roles in Identity ASP.NET Core 2.1 (Identity Scaffolded) 更改 ASP.NET Core Identity UI 中的路由? - Change routing in ASP.NET Core Identity UI? 如何在 ASP.NET Core 3.1 MVC 中进行自定义路由 - How to do custom routing in ASP.NET Core 3.1 MVC ASP.NET Core 2.1中的重定向路由 - Redirect routing in ASP.NET Core 2.1 ASP.NET Core 2.1中的Scaffold Identity UI,并添加全局筛选器 - Scaffold Identity UI in ASP.NET Core 2.1 and add Global Filter 如何在ASP.NET Core 2.1中的View中填充自定义类 - How fill custom class in View in asp.net core 2.1 如何在 asp.net core 2.1 中使用自定义消息设置状态代码? - How do I set the status code with custom message in asp.net core 2.1? ASP.NET Core(2.1)中的身份:为什么我们需要添加新的Context来自定义IdentityUser? - Identity in ASP.NET Core (2.1): Why do we need to add a new Context to customize IdentityUser? 带有 LDAP 身份验证的 Asp.Net Core 2.1 身份 - Asp.Net Core 2.1 Identity with LDAP authentication
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM