MVC: How to manage slahses in URL int the first route parameter

前端 未结 4 1391
忘掉有多难
忘掉有多难 2021-01-12 10:01

I need to map two variables that could contain slashes, to a controller, in my ASP MVC application. Let\'s see this with an example.

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-12 10:07

    You cannot do this mapping correctly, because of nature of this problem. Try to get a pencil and map following URL to repository and path:

    http://mysite/rep/Items/Items/Items/Items/Items/Items/Items/Items/Items
    

    There are multiple mappings:

    1) Repository = Items Path = Items/Items/Items/Items/Items/Items/Items

    2) Repository = Items/Items Path = Items/Items/Items/Items/Items/Items

    and so on....

    So either you should

    1. Pass parameters as query string
    2. Define multiple routes for each of format of repository (and add parts to full repository name in controller method)

提交回复
热议问题