Writing to a read only session in MVC 3+

前端 未结 1 1348
感情败类
感情败类 2020-12-15 17:12

I\'ve come across a curious behaviour of ASP sessions. You can force a controller to be outside of the user\'s session - I want to be able to do this so that multiple reques

相关标签:
1条回答
  • 2020-12-15 17:40

    ~/Sample/SetTest?value=foo

    Yes it won't throw any error, but it also didn't persist the session at the end of the request. By design any thing that you write to session gets updated (only if the session is writable) at the very end of the request life-cycle.

    In my test ~/Sample/Test returns nothing.

    I think they should have failed fast here when the session is readonly.

    By the way your sample need to be rewritten

    string test = (string)this.Session["test"]; 
    
    0 讨论(0)
提交回复
热议问题