I recently made my first MVC3 application that uses a SQLCompact 4 database (through EF4.1 code first). It runs fine on several browsers开发者_如何转开发. However, when I use it from my WindowsPhone 7 phone sometimes I run into concurrency errors and are form postings not carried out. Is there some catch that I need to be aware off?
EDIT: What happens (but not consistently):
- I update some data on IE mobile on the Edit.cshtml page.
- After posting the engine sends back a Details.cshtml that shows that the data has NOT been updated
- However, when I check with another browser the data HAS been updated.
- I follow the ActionLInk to the Edit.cshtml page again and try to update the data again.
- On posting the DbConcurrency exception occurs on the server, which is then handled (by refreshing the context). This sends back the Edit page once more.
- Now, on posting everything is fine.
This behaviour cannot be reproduced on any other browser, Apple's included. I even had a soft reset of my phone yesterday on posting!
- I update some data on IE mobile on the Edit.cshtml page.
- After posting the engine sends back a Details.cshtml that shows that the data has NOT been updated
- However, when I check with another browser the data HAS been updated.
That looks more like a caching issue in the browser on the mobile device to me.
How do you do your post, is it through AJAX or just with <input type="submit".. />
Hmmm
On posting the DbConcurrency exception occurs on the server, which is then handled (by refreshing the context). This sends back the Edit page once more.
Does this indicate that your context is still alive from the previous post back?
Found this on MSDN
Exception thrown by DbContext when the expected behavior is that SaveChanges for an entity would result in a database update but in fact no rows in the database were affected. This usually indicates that the database has been concurrently updated and a concurrency token that was expected to match did not actually match. State entries referenced by this exception are not serialized due to security and access to the state entries after serialization will return null.
Which could be interpreted that the second post made actually doesn't do an update, or is my interpretation wrong?
I'm still thinking of caching somehow, OutputCaching
could produce this problem sometimes in my experience, but I think that would affect all browser, not sure though.
精彩评论