- Modern Web Development with ASP.NET Core 3
- Ricardo Peres
- 119字
- 2021-06-18 18:35:57
Route configuration
There are a few options we can configure for route generation, all of which are configured through the AddRouting extension method over the services definition:
services.AddRouting(options =>
{
options.LowercaseUrls = true;
options.AppendTrailingSlash = true;
options.ConstraintMap.Add("evenint", typeof(EvenIntRouteConstraint));
});
The RouteOptions class supports the following properties:
- AppendTrailingSlash: Determines whether or not a trailing slash (/) should be appended to all generated URLs; the default is false (meaning it shouldn't)
- LowercaseUrls: Determines whether or not the generated URLs should be lowercase; the default is false
- ConstraintMap: Determines where constraints are mapped; more on this when we talk about route constraints
But route configuration does not end here—the next section is actually the most important one: Creating routing tables.
推薦閱讀
- 復(fù)雜軟件設(shè)計(jì)之道:領(lǐng)域驅(qū)動(dòng)設(shè)計(jì)全面解析與實(shí)戰(zhàn)
- C#完全自學(xué)教程
- Android 9 Development Cookbook(Third Edition)
- Linux環(huán)境編程:從應(yīng)用到內(nèi)核
- C語(yǔ)言程序設(shè)計(jì)學(xué)習(xí)指導(dǎo)與習(xí)題解答
- Teaching with Google Classroom
- Clojure Reactive Programming
- Mastering ROS for Robotics Programming
- OpenCV 4計(jì)算機(jī)視覺(jué)項(xiàng)目實(shí)戰(zhàn)(原書(shū)第2版)
- R數(shù)據(jù)科學(xué)實(shí)戰(zhàn):工具詳解與案例分析
- Spring Security Essentials
- iOS開(kāi)發(fā)項(xiàng)目化入門教程
- Advanced Python Programming
- Android 5從入門到精通
- C語(yǔ)言從入門到精通(微視頻精編版)