How do you persist querystring values in asp.net mvc?

前端 未结 4 1777
独厮守ぢ
独厮守ぢ 2021-01-01 21:24

What is a good way to persist querystring values in asp.net mvc?

If I have a url: /questions?page=2&sort=newest&items=50&showcomments=1&search=abcd

4条回答
  •  情深已故
    2021-01-01 21:51

    I would process the QueryString in the view (your option #1), instead of passing it in from the controller. This approach makes the view more self-contained, allowing you to convert it into a view control and re-use it across different views.

    Note: Accessing the QueryString directly in the view may seem like a violation of the design principle of separating the Model and View, but in reality this data is a navigational concern which is related to the view, not really part of the model.

提交回复
热议问题