Make session readonly on asp.net programmatically (EnableSessionState=“ReadOnly”)

前端 未结 2 1416
难免孤独
难免孤独 2020-12-19 06:59

I need to make the session readonly so I can establish multiple requests to a page that uses sessions variables but in the readonly mode.

Since all the process are p

2条回答
  •  天涯浪人
    2020-12-19 07:17

    If you use ASP.NET MVC, you can use the SessionStateAttribute class on the controller level.

    [SessionState(SessionStateBehavior.ReadOnly)]
    

    If you want to control the behavior on an action level, you can use this:

    https://www.c-sharpcorner.com/UploadFile/ff2f08/session-state-behavior-per-action-in-Asp-Net-mvc/

    If you use ASP.NET Web Forms, I am not quite sure, but it should be something along these lines...

提交回复
热议问题