- 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.
- 網(wǎng)絡(luò)協(xié)議工程
- C++黑客編程揭秘與防范
- 網(wǎng)絡(luò)創(chuàng)新指數(shù)研究
- Proxmox High Availability
- 物聯(lián)網(wǎng)信息安全
- 局域網(wǎng)組建、管理與維護(hù)項目教程(Windows Server 2003)
- 網(wǎng)管員必讀:網(wǎng)絡(luò)管理(第2版)
- C/C++串口通信:典型應(yīng)用實例編程實踐
- 6G無線網(wǎng)絡(luò)空口關(guān)鍵技術(shù)
- Practical Web Penetration Testing
- Implementing NetScaler VPX?
- 計算機網(wǎng)絡(luò)技術(shù)
- 現(xiàn)場綜合化網(wǎng)絡(luò)運營與維護(hù):運營商數(shù)字化轉(zhuǎn)型技術(shù)與實踐
- 5G時代:生活方式和商業(yè)模式的大變革
- 一板成功:高速電路研發(fā)與設(shè)計典型故障案例解析