diff --git a/src/Umbraco.Web/Macros/PartialViewMacroController.cs b/src/Umbraco.Web/Macros/PartialViewMacroController.cs
new file mode 100644
index 0000000000..c01731e989
--- /dev/null
+++ b/src/Umbraco.Web/Macros/PartialViewMacroController.cs
@@ -0,0 +1,39 @@
+using System.Collections.Generic;
+using System.Web.Mvc;
+using Umbraco.Web.Models;
+using umbraco.cms.businesslogic.macro;
+using umbraco.interfaces;
+using System.Linq;
+
+namespace Umbraco.Web.Macros
+{
+ ///
+ /// Controller to render macro content for Parital View Macros
+ ///
+ internal class PartialViewMacroController : Controller
+ {
+ private readonly UmbracoContext _umbracoContext;
+ private readonly MacroModel _macro;
+ private readonly INode _currentPage;
+
+ public PartialViewMacroController(UmbracoContext umbracoContext, MacroModel macro, INode currentPage)
+ {
+ _umbracoContext = umbracoContext;
+ _macro = macro;
+ _currentPage = currentPage;
+ }
+
+ ///
+ /// Child action to render a macro
+ ///
+ ///
+ [ChildActionOnly]
+ public PartialViewResult Index()
+ {
+ var model = new PartialViewMacroModel(_currentPage.ConvertFromNode(),
+ _macro.Properties.ToDictionary(x => x.Key, x => (object)x.Value));
+ return PartialView(_macro.ScriptName, model);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs b/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs
index cb2a67d075..600d2d1fd6 100644
--- a/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs
+++ b/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs
@@ -8,47 +8,12 @@ using System.Web.Mvc;
using System.Web.Routing;
using System.Web.WebPages;
using Umbraco.Core.IO;
-using Umbraco.Web.Models;
using umbraco.cms.businesslogic.macro;
using umbraco.interfaces;
using Umbraco.Web.Mvc;
namespace Umbraco.Web.Macros
{
- ///
- /// Controller to render macro content
- ///
- internal class PartialViewMacroController : Controller
- {
- private readonly UmbracoContext _umbracoContext;
- private readonly MacroModel _macro;
- private readonly INode _currentPage;
-
- public PartialViewMacroController(UmbracoContext umbracoContext, MacroModel macro, INode currentPage)
- {
- _umbracoContext = umbracoContext;
- _macro = macro;
- _currentPage = currentPage;
- }
-
- ///
- /// Child action to render a macro
- ///
- ///
- [ChildActionOnly]
- public PartialViewResult Index()
- {
- var model = new PartialViewMacroModel(_currentPage.ConvertFromNode(), new Dictionary());
- return PartialView(_macro.ScriptName, model);
- }
-
- }
-
- public abstract class PartialViewMacroPage : WebViewPage
- {
-
- }
-
///
/// A macro engine using MVC Partial Views to execute
///
@@ -135,11 +100,26 @@ namespace Umbraco.Web.Macros
var routeVals = new RouteData();
routeVals.Values.Add("controller", "PartialViewMacro");
routeVals.Values.Add("action", "Index");
+ routeVals.DataTokens.Add("umbraco-context", umbCtx); //required for UmbracoViewPage
+
+ ////lets render this controller as a child action if we are currently executing using MVC
+ ////(otherwise don't do this since we're using webforms)
+ //var mvcHandler = http.CurrentHandler as MvcHandler;
+ //if (mvcHandler != null)
+ //{
+ // routeVals.DataTokens.Add("ParentActionViewContext",
+ // //If we could get access to the currently executing controller we could do this but this is nearly
+ // //impossible. The only way to do that would be to store the controller instance in the route values
+ // //in the base class of the UmbracoController.... but not sure the reprocussions of that, i think it could
+ // //work but is a bit nasty.
+ // new ViewContext());
+ //}
+
var request = new RequestContext(http, routeVals);
string output;
using (var controller = new PartialViewMacroController(umbCtx, macro, currentPage))
{
- controller.ControllerContext = new ControllerContext(request, controller);
+ controller.ControllerContext = new ControllerContext(request, controller);
var result = controller.Index();
output = controller.RenderViewResultAsString(result);
}
diff --git a/src/Umbraco.Web/Macros/PartialViewMacroPage.cs b/src/Umbraco.Web/Macros/PartialViewMacroPage.cs
new file mode 100644
index 0000000000..a64e48663f
--- /dev/null
+++ b/src/Umbraco.Web/Macros/PartialViewMacroPage.cs
@@ -0,0 +1,14 @@
+using System.Web.Mvc;
+using Umbraco.Web.Models;
+using Umbraco.Web.Mvc;
+
+namespace Umbraco.Web.Macros
+{
+ ///
+ /// The base view class that PartialViewMacro views need to inherit from
+ ///
+ public abstract class PartialViewMacroPage : UmbracoViewPage
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index d97813b01e..0f023ad033 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -249,7 +249,9 @@
+
+