ASP.NET routing: Literal sub-segment between tokens, and route values with a character from the literal sub-segment

前端 未结 3 1318
暖寄归人
暖寄归人 2020-12-18 23:51

The reason I\'m asking is because IIS protects certain ASP.NET folders, like Bin, App_Data, App_Code, etc. Even if the URL does not map to an actual file system folder IIS r

相关标签:
3条回答
  • 2020-12-19 00:18

    Ok, I have a definitive answer. Yes, this is a bug. However, at this point I regret to say we have no plans to fix it for a couple of reasons:

    • It's a breaking change and could be a very hard to notice one at that.
    • There's an easy workaround.

    What you can do is change the URL to not have the underscore:

    {controller}/{action}/_{id}
    

    Then add a route constraint that requires that the ID parameter starts with an underscore character.

    Then within your action method you trim off the underscore prefix from the id parameter. You could even write an action filter to do this for you if you liked. Sorry for the inconvenience.

    0 讨论(0)
  • 2020-12-19 00:29

    With ASP.NET MVC if you look at the source they have a hard-coded value for the path separator (/) and to my knowledge cannot be changed.

    0 讨论(0)
  • 2020-12-19 00:30

    You can use characters that are not allowed for a directory or file name like: *,?,:,",<,>,|.

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