Correct optional route parameters on browsing url

后端 未结 1 1134
梦毁少年i
梦毁少年i 2021-01-26 18:26

I am working on Ecommerce project (Asp.Net Mvc3). My routes for product and categories are mentioned below

routes.MapLocalizedRoute(
  \"Product\",
  \"p/{produc         


        
相关标签:
1条回答
  • 2021-01-26 18:43

    This is referred to as a 'slug' and is typically handled in an action filter. Phil Haack has a good article Manipulating Action Method Parameters that explains it in detail. The basic concept is to handle the filters OnActionExecuting method to extract the route value for the ID parameter, then look up the corresponding name from the database and add that value to the Name parameter.

    0 讨论(0)
提交回复
热议问题