如何在核心 2.1 标识 UI asp.net 进行自定义路由?



当我添加路由"/海报/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

如何在核心 2.1 标识 UI 中执行这种类型的自定义路由 asp.net

只需使用 AddPageRoute 方法添加路由,如以下代码:

选项。TConvention.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">

相关内容

  • 没有找到相关文章

最新更新