.NET MVC and secure data transfer between pages

some background information. I have been using web forms for most of my career and have recently become interested in .NET MVC. I understand that it should be stateless, but I do not understand how this is fully practicable. In the form application, the user authenticates, and I return the user ID and some roles that are then put into this user session. When I need it, all I need to do is pull it out of the session, and I have it. From what I read, session and MVC are mutually exclusive. I read that you can use TempData to pass values, but it is saved only when you visit one page, and then it does not. Is there a standard way that data can be “stored” on the MVC site, in addition to adding redundant code for each controller where I want to transfer data?

+3
source share
2 answers

I think there might be some confusion here. What is truly stateless here is the HTTP protocol. ASP.NET WebForms is a technology designed to create and create a framework that bypasses HTTP statelessness and builds a stateful application infrastructure. That's why you see things in WebForms, such as ViewState, that essentially carry the state of the application along the pipe.

ASP.NET MVC came and took a different approach. It covers HTTP statelessness. This is why MVC does not have a ViewState.

, . (, ) , , ( IIS - ).

, , - (, Session, Application, Cache), . , , ; , .

+3

ASP.NET MVC Framework ASP.NET, ASP.NET MVC:

Session["MyVar"] = "SomeValue";
+2

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


All Articles