I am working on a Web API project using Asp Net Core 2.1. My existing Web API has the following Get method (and numerous other methods like these):
[HttpGet("GetEmployeByName/{Name}")]
public Employee GetEmployeeByName(string name)
{... some code...}
This responds to the following incoming request:
http://localhost:8080/Employee/GetEmployeeByName/{Name}
Now my requirement is such that some of the APIs could be called by passing an additional id such as:
http://localhost:8080/Employee/{Id}/GetEmployeeByName/{Name}.
I still need to map it to the original method without changing the route. This can be done using ASP Net Core's feature of URL Rewrite and the URL can be re-written without the id.
However what i want to do is to capture the {Id} as well and save it to Session\ Context.
Does anyone know how to extract the id and rewrite the URL.