asp.NET: Unknown length MVC paths

前端 未结 3 1167
悲&欢浪女
悲&欢浪女 2020-12-16 08:33

I am building a MVC application in asp.NET for a web portal. I have prepared a series of controllers, and mapped all the paths that don\'t macth to this to a Page controller

3条回答
  •  星月不相逢
    2020-12-16 09:19

    As far as i know, you can use regular expressions to express what the routes can look like (see the bottom code section here). With this, it should be possible to make a regex-string that can take an undetermined number of sub-sections ("forward-slashe and text/number-groups"). You can then parse the URL string in your application and retrieve the appropriate section.

    I am, however, not capable of writing this regex-string by myself without spending hours, so someone else can probably help you there. :-)

提交回复
热议问题