Reputation: 73
Is it possible to create this kind of route:
"param1 / param2 / *"
*
, everything that comes after param1 / param2 and also I want a default for this, which will redirect always to param1 / param2 /
?Pseudocode:
routes.MapRoute(
name: "Default",
url: "AppController/Index/*",
defaults: new { controller = "AppController", action = "Index" }
);
Example:
AppController / Index / test / qwe / 123
-> expect it to be redirected to AppController / Index
And also could this be solved in RouteConfig or should it be some rule in web.config? Or other solution are welcome too :)
Upvotes: 0
Views: 54
Reputation: 73
url: "AppController/Index/{.*}",
{.*}
Simple regex fixed my problem.
Upvotes: 1
Reputation: 21
You can do this in methods
...
[HttpGet("{id}")]
public void test(string id)
{
return Ok(id);
}
uri: localhost:{port}/api/test/{id}
Upvotes: 0