ASP NET MVC custom route fallback
I'm wondering if it is possibile to customize routing in a way that all requests are evaluated by a piece of code, redirected to the relevant controller if a match is found or passed to next rout i开发者_JAVA百科n list if not found.
sample request: /my coolpage/another one
the code searches and determine that the right controller for this is Page, action is "list" and id is "123" and so redirects
another request: /products/list/5
code finds no match al passes it back to next route that knows how to handle it...
any idea on how to do this?
Custom Route class
If you really need this kind of request mangling and you can't do it with IIS URL Rewriting module, then writing your own Route class is your best bet. You will probably have to write some other parts as well, but a custom Route class will be your starting point.
精彩评论