开发者

.NET custom session state provider: not persisting across pages...sometimes

开发者 https://www.devze.com 2023-03-14 20:48 出处:网络
I\'ve implemented a custom session 开发者_运维百科state provider for Oracle in my application. It seems to run smoothly (without errors!), but I\'m having trouble retrieving some Session variables whe

I've implemented a custom session 开发者_运维百科state provider for Oracle in my application. It seems to run smoothly (without errors!), but I'm having trouble retrieving some Session variables when I redirect to another page. But it doesn't happen all the time.

When the Session starts, I load a User object into Session. It stays there, because when the user gets to the starting page (and is authenticated), the app still recognizes him. It has no problem retrieving the User object from Session.

But if I pass a value into Session on one of my pages inside the app, then redirect to another page in order to utilize that Session variable, the new page retrieves null from the same named Session variable. Using the Visual Studio Watch window, I can actually see its value change from "100" (or whatever) to null. I don't get it.

The session provider seems to be working correctly because as I said, I'm able to persist some variables. Does someone know what the reason might be for Session to "lose" a value? Thanks.


If you are doing a response.redirect in the page, that can cause the thread to abort before the Session is written back to the database.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号