Enhancements and Bugs Forum


Shared Object Context In MvcCms

 
If you are using a version of MvcCms downloaded before 10/08/09 you will want to update your MvcCms.Data project at a minimum to take advantage of a bug fix that will effect your application.


The update involves the binding of the ObjectContext to the HTTPContext. Your get statement for MvcCmsEntities should look like the below.


string objectContextKey = HttpContext.Current.GetHashCode().ToString();
if (!HttpContext.Current.Items.Contains(objectContextKey))
{
    try
    {
        HttpContext.Current.Items.Add(objectContextKey, new MvcCmsEntities());
    }
    catch (Exception ex)
    {
        string s = ex.Message;
    }
}
mvccmsEntities = HttpContext.Current.ItemsobjectContextKey as MvcCmsEntities;
return mvccmsEntities;

If you need any help upgrading your version to just this part let me know and I can give you a hand.
9 months 4 days ago by jon

Replies