I am creating a custom route in asp.net MVC3 application and I want to create a route constraint whi开发者_如何学Pythonch will check if the url has integer as second part of the parameter. If so, I need to redirect to different action.
product/12
product/12-2-1990Here's how I do it.
    ''# MapRoute allows for a dynamic product ID
    routes.MapRoute("Products", "product/{id}",
                             New With {.controller = "product",
                                       .action = "index"},
                             New With {.id = "[0-9]+") ''# this forces the ID to only be a number.
Then you will create your redirect logic separately. I would recommend using an ActionFilter to do your redirect work. You write it once and it can be implemented all over.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论