Developing ASP.NET MVC Web Applications — Question 177

You are developing an ASP.NET MVC application that will be deployed to servers on multiple networks.
The application must be compatible with multiple browsers. You must track the page number that the user is viewing in search results.
You need to program the location for storing state information.
Where should you persist state information?

Answer options

Correct answer: B

Explanation

The correct answer is B, QueryString, because it allows the page number to be sent as part of the URL, making it easily accessible across different browsers. Session and Application store state server-side and would not directly allow tracking through the URL, while TempData is designed for short-lived data transfer between requests, making it unsuitable for persistent state information like a page number in search results.