Where to store logged user information on ASP.NET MVC using Forms Authentication?

前端 未结 4 1031
情深已故
情深已故 2020-12-23 21:34

I\'m using ASP.NET MVC and Forms Authentication on my application. Basically I use FormsAuthentication.SetAuthCookie to login and FormsAuthentication.Sig

4条回答
  •  半阙折子戏
    2020-12-23 22:25

    Well you will have to store these somewhere. Two main possible places though:

    The server

    You can either put them into Session. I suggest you do create a separate class that will hold only data that you actually need to avoid of wasting too much memory. Or you can also store into Cache that can end up in having many DB calls when there are huge amounts of concurrent users.

    The client

    In this case if you can limit the amount of data with a separate class, to that and use whatever way to serialize it and send it to the client. Either in a cookie or in URI (if length permits and cookies are disabled)...

    Outcome of these thoughts:
    the main thing here would be to create a separate class if you gain much memory resources this way. So that's the first thing you should do.

提交回复
热议问题