Asp.net Sessions Getting Crossed / Mixed Up

后端 未结 7 764
北恋
北恋 2020-12-04 20:19

Few weeks ago we had one of our customers contacting us saying that sometimes when he creates an activity it gets created under someone else\'s name!

We did some t

7条回答
  •  伪装坚强ぢ
    2020-12-04 20:54

    We had the same problem at the company I work at. We also realized that it was caused by output caching, which resulted in sending someone else's SessionId to the wrong person.

    We have now added the following element to our web.config.

    
      [...]
      
        [...]
        
        
      
      [..]
    
    

    We can't guarantee this will solve it, because the problem is almost impossible to reproduce, but based on our research, this should solve it.

    Strangely, the link to a Microsoft article describing this problem that can be found on the internet gives some general page as if the page has been deleted.

    But there is this Microsoft article that seems to describe the same issue voor IIS 6:

    An ASP.NET page is stored in the HTTP.sys kernel cache in IIS 6.0 when the ASP.NET page generates an HTTP header that contains a Set-Cookie response

    Which describes the symptom as:

    Consider the following scenario. A Microsoft ASP.NET page contains the <%@ OutputCache %> directive. Additionally, the ASP.NET page generates an HTTP header that contains a Set-Cookie response. In this scenario, the ASP.NET page is stored in the HTTP protocol stack (HTTP.sys) kernel cache in Microsoft Internet Information Services (IIS) 6.0. Therefore, multiple users who access the same page may receive identical cookies.

    Update

    I found this really good article at Microsoft Premier Developer blog that explains a lot:

    ASP.Net Session Swapping – Why it happens and what can be done about it?

提交回复
热议问题