- Hands-On Full:Stack Web Development with ASP.NET Core
- Tamir Dresher Amir Zuker Shay Friedman
- 238字
- 2021-06-10 19:37:29
Conventional routing
In the conventional routing style, during application startup, you define route templates that will be queried each time an incoming request is received in order to make a URL matching. This process will eventually map to a controller and a method inside it. If no route is found for the incoming request, an HTTP error of 404 (Not Found) will be returned to the caller.
When you called AddMvc inside the ConfigureServices method and the UseMvcWithDefaultRoute method inside the Configure method in your startup class, at the same time, behind the scenes, the MVC framework added a route handler and set the route to the default template, which looks like this:
"{controller=Home}/{action=Index}/{id?}"
This template defines that for every request that is received, the request pipeline will attempt to break its URL so that the first part will be mapped to the controller name, the second part (the one after the /) will be mapped to the method inside the controller, and the third part, if it exists, will be used as a route parameter (enclosed in curly braces {}) to map to a parameter with the id method.
When ASP.NET Core searches for a controller, it takes the controller part from the template and concatenates it with the suffix controller. This means that, instead of using a URL in the form of /ExampleController/SomeAction, you can just write /Example/SomeAction.
- 物聯(lián)網(wǎng)安全(原書第2版)
- 工業(yè)控制網(wǎng)絡(luò)安全技術(shù)與實(shí)踐
- HCNA網(wǎng)絡(luò)技術(shù)
- JBoss EAP6 High Availability
- 無人機(jī)通信
- SSL VPN : Understanding, evaluating and planning secure, web/based remote access
- 計(jì)算機(jī)網(wǎng)絡(luò)原理與應(yīng)用技術(shù)
- 2小時(shí)讀懂物聯(lián)網(wǎng)
- Learning Node.js Development
- 華為HCIA-Datacom認(rèn)證指南
- Cisco無線局域網(wǎng)配置基礎(chǔ)
- 通信系統(tǒng)實(shí)戰(zhàn)筆記:無處不在的信號(hào)處理
- Twilio Cookbook(Second Edition)
- 企業(yè)網(wǎng)絡(luò)組建與維護(hù)項(xiàng)目式教程
- 網(wǎng)絡(luò)安全和信息化黨政領(lǐng)導(dǎo)干部一本通