1 回答

TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超6個(gè)贊
您可以將它們放在另一個(gè)文件中:
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+" }
);
}
);
}
}
然后在“啟動(dòng)”類中調(diào)用它:
public class Startup
{
...
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
...
app.UseStaticFiles();
Routing.Include(app);
...
}
}
- 1 回答
- 0 關(guān)注
- 120 瀏覽
添加回答
舉報(bào)