'Routing in ASP.NET Core MVC
How can I create a route like this in the url
Localhost:4578//Home/Index/1/2/3/4/5/6
I tried making a custom url using routing in ASP.NET Core 3.1 MVC.
Solution 1:[1]
First you cannot use double slash after your port number,
Imagine, you have a CategoryController
Its class name will be like this
[Route("admin/category")]
public class CategoryController : Controller
and after that you will have a method returning ActionResult or something else in this controller
[Route("upper-categories/add")]
public async ActionResult UpperCategoryAdd()
You access this method by using /admin/category/upper-categories/add
and if you want to use an id or something like that
you should use {id} on it
[Route("upper-categories/edit/{id}")]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | srhtyt1 |
