开发者

MVC controllers bubbling back into the router?

开发者 https://www.devze.com 2023-03-20 05:04 出处:网络
I have a URL scheme like this: website.com/keywords and I also have specific controllers: website.com/controller/action

I have a URL scheme like this:

website.com/keywords

and I also have specific controllers:

website.com/controller/action

Sometimes the keyw开发者_高级运维ords 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消