Repeated cookie query or Storing in viewstate? Which is the better practice?

前端 未结 4 601
旧时难觅i
旧时难觅i 2021-01-23 18:37

I have a internal website that users log into. This data is saved as a cookie. From there the users go on their merry way. Every so often the application(s) will query the au

4条回答
  •  我在风中等你
    2021-01-23 19:17

    Viewstate is specific to the page they are viewing, so its gone once they go along thier merry way. Not a good way to persist data.

    Your best bet is to use Forms Authentication, its built in to ASP.NET and you can also shove any user-specific information into the Forms Authentication Ticket's Value. You can get 4000 bytes in (after encrypting) there that should hold whatever you need. It will also take care of allowing and denying users access to pages on the site, and you can set it to expire whenever you need.

    Storing in the session is a no-no because it scales VERY poorly (eats up resources on the server), and it can be annoying to users with multiple browser connections to the same server. It is sometimes unavoidable, but you should take great pains to avoid it if you can.

提交回复
热议问题