Be careful with session variables; itβs easy to open multiple pages that all use the same session and end up mixing values.
It is better to use TempData , which allows you to use the value only once (it is deleted at first access). However, this means that the value will be used almost immediately.
You can also write a cookie with the desired value, intercept the request (ASP.Net provides many ways to do this, such as the BeginRequest event), and internally handle the URL as if it contained the value,
Of course, you must clear the cookie (which will have the same problem as the session-based solution). Remember that cookies are more vulnerable to interference with the client.
Personally, I believe that any of these approaches is far more problematic than worth it. " Hackable URLs " (for example, those that contain a potentially significant identifier) ββare generally good.
source share