Wondering if anyone has attempted to use Matrix URI's with ASP.NET Core?
We're building an Angular front-end that uses their version called Route Parameters
. The front-end will need to make a similar call to our back-end and it's build on ASP.NET Core. However I'm not really able to locate any information about it in Microsoft's routing docs. Perhaps Microsoft is calling it by a different name, like Angular does.
Matrix URI looks like: http://some.url.com;foo=bar;baz=bing
There are a couple of good answers that talk about what they are, I just can't seem to find anything related to ASP.NET Core.
- Navigating back to the list component have to scroll down to the bottom of the section, just before 'Route parameters in the ActivatedRoute service'.
- Angular2 with matrix url notation
- URL matrix parameters vs. request parameters
Any information/advice on implementing matrix URI in an ASP.NET Core API would be greatly appreciated. Thanks.
I've been thinking about something similar recently. Matrix URIs are nothing new, but not widely known or used. I stumbled on this question and left empty handed.
After more research, I settled on writing a custom modelbinder. I started by creating a stub to explore how custom modelbinders work but when I went to wire it up to my controller method, I had a random thought... What if I just used the HttpGet template to tell Web API how to parse the URI and extract the matrix properties.
It worked! Here's the code:
FWIW I'm using .net 5 but I'm reasonably certain this works at least as of .net core 3.
Hopefully this helps the next person who lands on this question!