Asp.Net MVC: How do I enable dashes in my urls?

前端 未结 9 1044
礼貌的吻别
礼貌的吻别 2020-11-28 21:52

I\'d like to have dashes separate words in my URLs. So instead of:

/MyController/MyAction

I\'d like:

/My-Controller/My-Act         


        
9条回答
  •  一生所求
    2020-11-28 22:56

    You could write a custom route that derives from the Route class GetRouteData to strip dashes, but when you call the APIs to generate a URL, you'll have to remember to include the dashes for action name and controller name.

    That shouldn't be too hard.

提交回复
热议问题