0

I'm writing a HATEOAS-driven REST API and it would be convenient to return responses from some actions with links to other resources.

As the REST API is currently implemented following a monolithic architecture, and in order to not only reduce redundancies but also simplify the job of migrating some parts to microservices, it would be nice if an action could send responses based on the URL that was routed to it.

So, does anyone know if ASP.NET core 2.1 offers any way to access the full URL that's routed to an action when a request is routed to said action?

RAM
  • 2,257
  • 2
  • 19
  • 41
  • It's not clear what you're asking. Please revise your question. – Chris Pratt Oct 04 '18 at 15:52
  • Possible duplicate of [How to access current absolute Uri from any ASP .Net Core class?](https://stackoverflow.com/questions/42547653/how-to-access-current-absolute-uri-from-any-asp-net-core-class) – Kirk Larkin Oct 04 '18 at 19:56
  • The question I've suggested as a *possible* duplicate should help. You can just use `Request` directly inside of an action rather than having to go via `IHttpContextAccessor` and `HttpContext`, but the rest (no pun intended) should apply as-is (I recommend [Shyju's answer](https://stackoverflow.com/a/43375481/2630078)). – Kirk Larkin Oct 04 '18 at 19:57

0 Answers0