1 回答
TA贡献1799条经验 获得超6个赞
您可以将它们放在另一个文件中:
public static class Routing
{
public static void Include(IApplicationBuilder app)
{
app.UseMvc(routes =>
{
// /
routes.MapRoute(null, "", new
{
controller = "Products",
action = "List",
category = "",
page = 1
});
// Page2
routes.MapRoute(null,
"Page{page}",
new
{
controller = "Products",
action = "List",
category = ""
},
new { page = @"\d+" }
);
}
);
}
}
然后在“启动”类中调用它:
public class Startup
{
...
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
...
app.UseStaticFiles();
Routing.Include(app);
...
}
}
- 1 回答
- 0 关注
- 94 浏览
添加回答
举报