diff --git a/src/Orchard.Web/Core/Contents/Controllers/ItemController.cs b/src/Orchard.Web/Core/Contents/Controllers/ItemController.cs index 38b1c4240..22357007c 100644 --- a/src/Orchard.Web/Core/Contents/Controllers/ItemController.cs +++ b/src/Orchard.Web/Core/Contents/Controllers/ItemController.cs @@ -9,9 +9,14 @@ namespace Orchard.Core.Contents.Controllers { [Themed] public class ItemController : Controller { private readonly IContentManager _contentManager; + private readonly IHttpContextAccessor _hca; - public ItemController(IContentManager contentManager, IShapeFactory shapeFactory, IOrchardServices services) { + public ItemController(IContentManager contentManager, + IShapeFactory shapeFactory, + IOrchardServices services, + IHttpContextAccessor hca) { _contentManager = contentManager; + _hca = hca; Shape = shapeFactory; Services = services; T = NullLocalizer.Instance; @@ -37,8 +42,12 @@ namespace Orchard.Core.Contents.Controllers { if (!Services.Authorizer.Authorize(Permissions.ViewContent, contentItem, T("Cannot view content"))) { return new HttpUnauthorizedResult(); } - + var model = _contentManager.BuildDisplay(contentItem); + if (_hca.Current().Request.IsAjaxRequest()) { + return new ShapePartialResult(this,model); + } + return View(model); } @@ -62,6 +71,10 @@ namespace Orchard.Core.Contents.Controllers { } var model = _contentManager.BuildDisplay(contentItem); + if (_hca.Current().Request.IsAjaxRequest()) { + return new ShapePartialResult(this, model); + } + return View(model); } }