0

I'm building a profile page with update form. After submitting the form with new data and several page refreshes I see sometime new and sometimes old data. It depends on thread handling current request. One thread contains new data and another one old. NHibernate is configured using ThreadStaticSessionContext and NoCacheProvider. In Autofac UserStore, OwinContext.Authentication and UserManager are configured as InstancePerRequest.

I tried to change ThreadStaticSessionContext to CallSessionContext and it started working normally. So the question is: why it works(ThreadStaticSessionContext is preferable for multithread apps) and what negative effects can it bring?

Thanks!

2
  • is this a windows or web app? Commented Aug 19, 2016 at 15:06
  • it's a web application. Commented Aug 22, 2016 at 13:04

1 Answer 1

0

ThreadStaticSessionContext is for long running processes such as windows services or windows apps. For web applications you want to be implementing Session Per Request. This is what the WebSessionContext is for.

I actually don't use any of the contexts and just wire it up myself. See my answer here for an example.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.