简体   繁体   中英

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 in 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM