ASP.Net MVC - handling bad URL parameters

前端 未结 5 1742
不知归路
不知归路 2021-02-01 07:21

What\'s the best way to handle a visitor constructing their own URL and replacing what we expect to be an ID with anything they like?

For example:

ASP.Net MVC -

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-01 08:09

    The problem with that approach is that they still might pass an integer which doesn't map to a page. Just return a 404 if they do that, just as you would with "foo". It's not something to worry about unless you have clear security implications.

提交回复
热议问题