开发者

MVC ASP.NET, ObjectContext and Ajax. Weird Behaviour

i've been creating a web application in mvc asp.net. I have three different project/solutions:

  • One solution contains the model in EF (DAL) and all the methods to add, update, delete and query the objects in the model, the objectcontext is managed here in a per request basis.
  • Other solution contains a content management system in wich authorized users insert, delete, update and access objects through the DAL mentioned before.
  • And the last solution contains the web page that is accessed by all users (thousands of u开发者_Go百科sers per day) and where the only operations executed are selects, no update, inserts or deletes here.

All the selects are executed against the DAL mentioned before (the first solution). The problem here is that i'm not sure whether an HttpContext lifespan ObjectContext is the best solution.

I have a lot of ajax calls in my web app and i'm not sure if an httpcontext could interfere with the performance of the application. I've been noticed that in some cases, specially when someone is working in the content manager inserting, updating or deleting, when you try to click on any link of the user web application (the web app that is accessed by any user - the third one that i mentioned before) the web page freezes and it remains stucked transferring data. In order to stop that behaviour you have to stop and refresh or click several times on the link. Excuse me for my bad english. I hope you could understand and could help me to solve this issue. Thanx in advance.


You need a new ObjectContext for every operation, because it's designed to be used for a unit of work. You want to dispose it after calling SaveChanges, because if you would use it to select from it after saving changes, you would get unexpected results.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜