Feather Dynamic Module Master / Detail Controller - The referenced OpenAccessContext or 'IObjectScope' is already closed
I opened an issue on GitHub for this, but I'm hoping to get some more eyes on this problem. You can find that issue here:
Master / Detail - The referenced OpenAccessContext or 'IObjectScope' is already closed #2366
Ultimately the problem is that the implementation of the Details action accepts the `DynamicContent` class, which is a context dependent object, outside of the scope of the context making this no longer a stateless operation and prevents deep-linking to a details item URL.
Hello Richard,
It is important to note that we do not use the same object for the master and for the details view. What i mean is that when you click on an item from the master view to open its details or just manually access the details page of an item (without visiting the master page), Sitefinity will resolve the item details from the url by the item UrlName.
When you access the item details Sitefinity gets the UrlName from the url and finds the item in the specified module type with this url name and uses this item in the Details action.
I have tested this on my side and was not able to reproduce the issue.
Here is the code I used in my controller for the Index() and Details() actions:
using
SitefinityWebApp.Mvc.Models.MyModule;
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.Mvc;
using
Telerik.Sitefinity.DynamicModules;
using
Telerik.Sitefinity.DynamicModules.Model;
using
Telerik.Sitefinity.GenericContent.Model;
using
Telerik.Sitefinity.Utilities.TypeConverters;
using
Telerik.Sitefinity.Model;
using
Telerik.Sitefinity.Mvc;
namespace
SitefinityWebApp.Mvc.Controllers
[ControllerToolboxItem(Name =
"MyModule widget"
, Title =
"MyModule widget"
, SectionName =
"MvcWidgets"
)]
public
class
MyModuleController : Controller
public
ActionResult Index(
int
? page)
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(String.Empty);
Type itemsType = TypeResolutionService.ResolveType(
"Telerik.Sitefinity.DynamicTypes.Model.MyModules.MyModule"
);
List<DynamicContent> myItems = dynamicModuleManager.GetDataItems(itemsType)
.Where(i => i.Status == ContentLifecycleStatus.Live && i.Visible ==
true
).ToList();
List<MyModuleModel> model =
new
List<MyModuleModel>();
foreach
(var item
in
myItems)
string
title = item.GetValue(
"Title"
).ToString();
string
urlName = item.GetValue(
"UrlName"
).ToString();
var modelItem =
new
MyModuleModel() Title = title, UrlName = urlName ;
model.Add(modelItem);
return
View(
"Default"
, model);
public
ActionResult Details(DynamicContent author)
var model =
new
MyModuleModel() Title = ((IHasTitle)author).GetTitle(), UrlName = author.UrlName ;
return
View(model);
I have the following model class:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
namespace
SitefinityWebApp.Mvc.Models.MyModule
public
class
MyModuleModel
public
string
Title
get
;
set
;
public
string
UrlName
get
;
set
;
In the Default View displaying the list of items I added this markup to display a link to the item:
@model List<
SitefinityWebApp.Mvc.Models.MyModule.MyModuleModel
>
@foreach (var item in Model)
<
div
>
<
a
href
=
'/page-url/@item.UrlName'
>@Html.Raw(item.Title)</
a
>
</
div
>
Then in the Details View I just display the Title of the item like below:
@model SitefinityWebApp.Mvc.Models.MyModule.MyModuleModel
@Model.Title
I also recorded a short video for your convenience to demonstrate the results on my side. I am also sending attached the MVC widget I used on my side.
I am afraid it is difficult to say what is causing the issue on your side. What I can suggest is that you send me the MVC widget you have developed on your side and any details that will help us to reproduce the issue and check if it caused by Sitefinity.
Regards,
Sabrie Nedzhip
Telerik