How can I replace custom placeholder before each route in .Net Core 2.1
For Example {serverkey}
[Route("api/{serverkey}/[controller]")]
[ApiController]
[AuthorizationFilter]
public class MonitoringController : Controller
{
// Code...
}
I want each url to be like api/key/Monitoring/Action
. So I need to replace key in each request/route.
So basically is there any way to replace the placeholder {serverkey}
or something like this {serverkey:key}
or even [serverkey]
before each request map to this controller.
I know there could be a way like [controller]
is replaced automatically by .net core
but I am not able to find it.
Thanks in advance.
{serverKey}
value coming from? – Jamie Rees[Route("api/{serverkey}/[controller]")]
attribute on top of your controller, and accessing the value in your action methods (like this[HttpGet] public string Get(string serverkey)
) isn't enough? – Bruno MartinsserverKey
in appsetting.json. But i need to find a way to replace route placeholder with this key. – Voodooserverkey
provided in the url doesn't match the one in the appsettings file? I think you could deal with that with a customAuthorizeAttribute
– Bruno Martins