ASP.NET MVC: Create an External Value

I have a simple website. Almost every action takes int toonIdas an argument (toonId does not equate the user: one user can own several toons).
Currently, I am providing this value to each view from the controller, and each link and submit button sends this value back to the controller.
It works. I'm just looking for an easier way to do this (AOP comes to mind).

I use cookies to save the β€œfavorite / default toon” and it works fine (used with ActionAttribute, which takes toonId from the cookie and passes it to toonId if no toonId was provided). But I want to also support cookie-less sessions.

Question . What is an easy way to add an environment variable to a page without passing it explicitly throughout? This way it will work with browsers without cookies.

Is ViewState a transition method (which should not be in MVC)?
Is there a server side session?

+3
source share
3 answers

This is exactly what the session is for.

Asp.net mvc does not have a page life cycle, so there is no viewstate.

0
source

, cookie, IRouteHandler. . IRouteHandler, , .

0

, "toonid". " ", , womp, . , somethign (, , ), .

0

Source: https://habr.com/ru/post/1729420/


All Articles