Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC controllers bubbling back into the router?

I have a URL scheme like this:

website.com/keywords

and I also have specific controllers:

website.com/controller/action

Sometimes the keywords may look an awful lot like controller URLs, or have some kind of "/url/thingy" on them. All of the keyword URLs will be stored in a database and return static content. What I'd love to be able to do, is have the "keywords" controller match first (it just uses {*}), and if the URL isn't found in the database, pop back out to the router, and let the matching continue.

I've got a workaround now which puts the universal matching router at the very end, and doing a 302 redirect to the proper controller, but that is a longer round-trip time and isn't necessary if I can pop back out.

like image 980
Bryan Boettcher Avatar asked Nov 05 '22 18:11

Bryan Boettcher


1 Answers

Not that i dont want to do the leg work on this one because i would love to have the answer as well but i did have this bookmarked on the subject. custom route constraint

if you go down about half way you can see how to create your custom route contraint; just search for Listing 2 – NotEqualConstraint.cs then you can pass in a cached list of those keywords or just have the custom route constraint hold onto the list of keywords itself.

like image 163
YetAnotherDeveloper Avatar answered Nov 09 '22 14:11

YetAnotherDeveloper