如何为包含许多剃须刀页面的Area文件夹定义新路径?

时间:2019-03-07 10:01:55

标签: asp.net-mvc razor asp.net-core razor-pages

是否可以通过简单的方法为包含许多剃须刀页面的区域文件夹定义新路线?

在mvc模式中,我们可以像这样轻松定义新路由:

routes.MapRoute(
   name: "auth",
   template: "auth/{action}",
   defaults: new { area = "Identity", controller = "Account", action = "Login" }
);

但是我无法在Startup.cs文件中为具有许多剃须刀页面的文件夹定义新路由。 我应该使用约定吗?

1 个答案:

答案 0 :(得分:0)

对于“区域剃刀页面”,无需定义约定路径。

按照URL https://localhost:44353/areaname/razorpagename访问剃须刀页面。

例如,如果您有Areas Folder之类的

enter image description here

通过Areas/Test/Pages/Index访问此https://localhost:44353/test/index