form data posted using linq-to-sql not showing until I refresh the page

Posted by PeteShack on Stack Overflow See other posts from Stack Overflow or by PeteShack
Published on 2010-06-10T04:14:06Z Indexed on 2010/06/10 4:22 UTC
Read the original article Hit count: 151

Filed under:
|

I have an asp.net mvc app with a form.

When you submit the form, it adds records to the sql database with linq-to-sql. After adding the records, the controller displays the form again, and should show those new values on the form. But, when it displays the form, the values are blank, until you refresh the page.

While tracing through the code, I can see the records being added to the database when they are submitted, but the view doesnt display them, unless I refresh. The view is not the problem, it just displays the view model, which is missing the new records immediately after the post.

I know this is kind of vague, but wasnt sure what parts of code to include here.

Could this have something to do with data context life cycle? Basically, there is a data context created when the form is posted, then a different data context is created in the method that displays the form.

Any suggestions on what might be causing this?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about linq-to-sql