Merge branch 'dev-v7-upgradablemvc5webapi2' of https://github.com/Shazwazza/Umbraco-CMS into Shazwazza-dev-v7-upgradablemvc5webapi2
Conflicts: build/UmbracoVersion.txt src/Umbraco.Core/Configuration/UmbracoVersion.cs
This commit is contained in:
@@ -36,7 +36,6 @@
|
||||
<file src="..\_BuildOutput\bin\Microsoft.ApplicationBlocks.Data.dll" target="lib\Microsoft.ApplicationBlocks.Data.dll" />
|
||||
<file src="..\_BuildOutput\bin\Microsoft.Threading.Tasks.dll" target="lib\Microsoft.Threading.Tasks.dll" />
|
||||
<file src="..\_BuildOutput\bin\Microsoft.Threading.Tasks.Extensions.dll" target="lib\Microsoft.Threading.Tasks.Extensions.dll" />
|
||||
<file src="..\_BuildOutput\bin\Microsoft.Web.Helpers.dll" target="lib\Microsoft.Web.Helpers.dll" />
|
||||
<file src="..\_BuildOutput\bin\Microsoft.Web.Infrastructure.dll" target="lib\Microsoft.Web.Infrastructure.dll" />
|
||||
<file src="..\_BuildOutput\bin\Microsoft.Web.Mvc.FixedDisplayModes.dll" target="lib\Microsoft.Web.Mvc.FixedDisplayModes.dll" />
|
||||
<file src="..\_BuildOutput\bin\MiniProfiler.dll" target="lib\MiniProfiler.dll" />
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
<language>en-US</language>
|
||||
<tags>umbraco</tags>
|
||||
<dependencies>
|
||||
<dependency id="Microsoft.AspNet.Mvc" version="[4.0.30506.0,5.0.0)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi" version="[4.0.30506,5.0.0)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi.WebHost" version="[4.0.30506, 5.0.0)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi.Core" version="[4.0.30506, 5.0.0)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi.Client" version="[4.0.30506, 5.0.0)" />
|
||||
<dependency id="Microsoft.AspNet.Mvc" version="[4.0.30506.0,6.0.0)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi" version="[4.0.30506,6.0.0)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi.WebHost" version="[4.0.30506, 6.0.0)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi.Core" version="[4.0.30506, 6.0.0)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi.Client" version="[4.0.30506, 6.0.0)" />
|
||||
<dependency id="Microsoft.AspNet.Mvc.FixedDisplayModes" version="1.0.1" />
|
||||
<dependency id="Microsoft.Net.Http" version="[2.0.20710.0, 3.0.0)" />
|
||||
<dependency id="MiniProfiler" version="[2.1.0, 3.0.0)" />
|
||||
@@ -48,7 +48,6 @@
|
||||
<file src="..\_BuildOutput\WebApp\bin\interfaces.xml" target="lib\interfaces.xml" />
|
||||
<file src="..\_BuildOutput\WebApp\bin\log4net.dll" target="lib\log4net.dll" />
|
||||
<file src="..\_BuildOutput\WebApp\bin\Microsoft.ApplicationBlocks.Data.dll" target="lib\Microsoft.ApplicationBlocks.Data.dll" />
|
||||
<file src="..\_BuildOutput\WebApp\bin\Microsoft.Web.Helpers.dll" target="lib\Microsoft.Web.Helpers.dll" />
|
||||
<file src="..\_BuildOutput\WebApp\bin\SQLCE4Umbraco.dll" target="lib\SQLCE4Umbraco.dll" />
|
||||
<file src="..\_BuildOutput\WebApp\bin\System.Data.SqlServerCe.dll" target="lib\System.Data.SqlServerCe.dll" />
|
||||
<file src="..\_BuildOutput\WebApp\bin\System.Data.SqlServerCe.Entity.dll" target="lib\System.Data.SqlServerCe.Entity.dll" />
|
||||
|
||||
@@ -27,7 +27,6 @@ if ($project) {
|
||||
if(Test-Path $umbracoBinFolder\interfaces.dll) { Remove-Item $umbracoBinFolder\interfaces.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\log4net.dll) { Remove-Item $umbracoBinFolder\log4net.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\Microsoft.ApplicationBlocks.Data.dll) { Remove-Item $umbracoBinFolder\Microsoft.ApplicationBlocks.Data.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\Microsoft.Web.Helpers.dll) { Remove-Item $umbracoBinFolder\Microsoft.Web.Helpers.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\SQLCE4Umbraco.dll) { Remove-Item $umbracoBinFolder\SQLCE4Umbraco.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\System.Data.SqlServerCe.dll) { Remove-Item $umbracoBinFolder\System.Data.SqlServerCe.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\System.Data.SqlServerCe.Entity.dll) { Remove-Item $umbracoBinFolder\System.Data.SqlServerCe.Entity.dll -Force -Confirm:$false }
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"": "underscore-min.{js,map}"
|
||||
},
|
||||
"jquery": {
|
||||
"": "jquery.min.{js,map}"
|
||||
"": "dist/jquery.min.{js,map}"
|
||||
},
|
||||
"jquery-file-upload": {
|
||||
"": "**/jquery.{fileupload,fileupload-process,fileupload-angular,fileupload-image}.js"
|
||||
|
||||
@@ -158,9 +158,6 @@
|
||||
<Reference Include="Microsoft.Threading.Tasks.Extensions">
|
||||
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.165\lib\net45\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Helpers">
|
||||
<HintPath>..\packages\Microsoft.Web.Helpers.1.0.0\lib\Microsoft.Web.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
@@ -2549,7 +2546,7 @@ xcopy "$(ProjectDir)"..\packages\SqlServerCE.4.0.0.0\x86\*.* "$(TargetDir)x86\"
|
||||
<WebProjectProperties>
|
||||
<UseIIS>True</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>7210</DevelopmentServerPort>
|
||||
<DevelopmentServerPort>7220</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:7220</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
<add namespace="Umbraco.Core" />
|
||||
<add namespace="Umbraco.Core.Models" />
|
||||
<add namespace="Umbraco.Web.Mvc" />
|
||||
<add namespace="Microsoft.Web.Helpers" />
|
||||
<add namespace="umbraco" />
|
||||
<add namespace="Examine" />
|
||||
</namespaces>
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
<package id="Microsoft.AspNet.WebPages" version="2.0.30506.0" targetFramework="net40" />
|
||||
<package id="Microsoft.Bcl.Async" version="1.0.165" targetFramework="net45" />
|
||||
<package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net45" />
|
||||
<package id="Microsoft.Web.Helpers" version="1.0.0" targetFramework="net40" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
|
||||
<package id="MiniProfiler" version="2.1.0" targetFramework="net45" />
|
||||
<package id="MySql.Data" version="6.6.5" targetFramework="net40" />
|
||||
|
||||
10
src/Umbraco.Web/Mvc/MvcVersionCheck.cs
Normal file
10
src/Umbraco.Web/Mvc/MvcVersionCheck.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Umbraco.Web.Mvc
|
||||
{
|
||||
internal class MvcVersionCheck
|
||||
{
|
||||
public static System.Version MvcVersion
|
||||
{
|
||||
get { return typeof (System.Web.Mvc.Controller).Assembly.GetName().Version; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Lucene.Net.Util;
|
||||
using Microsoft.Web.Mvc;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Web.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// A view engine to look into the App_Plugins folder for views for packaged controllers
|
||||
/// </summary>
|
||||
public class PluginViewEngine : FixedRazorViewEngine
|
||||
public class PluginViewEngine : ReflectedFixedRazorViewEngine
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
@@ -47,9 +48,9 @@ namespace Umbraco.Web.Mvc
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
AreaMasterLocationFormats = viewLocationsArray;
|
||||
AreaMasterLocationFormats = viewLocationsArray;
|
||||
|
||||
AreaPartialViewLocationFormats = new[]
|
||||
AreaPartialViewLocationFormats = new[]
|
||||
{
|
||||
//will be used when we have partial view and child action macros
|
||||
string.Concat(SystemDirectories.AppPlugins, "/{2}/Views/Partials/{0}.cshtml"),
|
||||
|
||||
98
src/Umbraco.Web/Mvc/ReflectedFixedRazorViewEngine.cs
Normal file
98
src/Umbraco.Web/Mvc/ReflectedFixedRazorViewEngine.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Umbraco.Web.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// This is here to support compatibility with both MVC4 and MVC5
|
||||
/// </summary>
|
||||
public abstract class ReflectedFixedRazorViewEngine : IViewEngine
|
||||
{
|
||||
protected ReflectedFixedRazorViewEngine()
|
||||
{
|
||||
if (MvcVersionCheck.MvcVersion >= System.Version.Parse("5.0.0"))
|
||||
{
|
||||
_wrappedEngine = new RazorViewEngine();
|
||||
}
|
||||
else
|
||||
{
|
||||
var assembly = Assembly.Load("Microsoft.Web.Mvc.FixedDisplayModes");
|
||||
var engineType = assembly.GetType("Microsoft.Web.Mvc.FixedRazorViewEngine");
|
||||
_wrappedEngine = (IViewEngine)Activator.CreateInstance(engineType);
|
||||
}
|
||||
}
|
||||
|
||||
public string[] ViewLocationFormats
|
||||
{
|
||||
get { return _viewLocationFormats; }
|
||||
set
|
||||
{
|
||||
_wrappedEngine.GetType().GetProperty("ViewLocationFormats").SetValue(_wrappedEngine, value);
|
||||
_viewLocationFormats = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string[] PartialViewLocationFormats
|
||||
{
|
||||
get { return _partialViewLocationFormats; }
|
||||
set
|
||||
{
|
||||
_wrappedEngine.GetType().GetProperty("PartialViewLocationFormats").SetValue(_wrappedEngine, value);
|
||||
_partialViewLocationFormats = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string[] AreaViewLocationFormats
|
||||
{
|
||||
get { return _areaViewLocationFormats; }
|
||||
set
|
||||
{
|
||||
_wrappedEngine.GetType().GetProperty("AreaViewLocationFormats").SetValue(_wrappedEngine, value);
|
||||
_areaViewLocationFormats = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string[] AreaMasterLocationFormats
|
||||
{
|
||||
get { return _areaMasterLocationFormats; }
|
||||
set
|
||||
{
|
||||
_wrappedEngine.GetType().GetProperty("AreaMasterLocationFormats").SetValue(_wrappedEngine, value);
|
||||
_areaMasterLocationFormats = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string[] AreaPartialViewLocationFormats
|
||||
{
|
||||
get { return _areaPartialViewLocationFormats; }
|
||||
set
|
||||
{
|
||||
_wrappedEngine.GetType().GetProperty("AreaPartialViewLocationFormats").SetValue(_wrappedEngine, value);
|
||||
_areaPartialViewLocationFormats = value;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly IViewEngine _wrappedEngine;
|
||||
private string[] _areaViewLocationFormats;
|
||||
private string[] _areaMasterLocationFormats;
|
||||
private string[] _areaPartialViewLocationFormats;
|
||||
private string[] _viewLocationFormats;
|
||||
private string[] _partialViewLocationFormats;
|
||||
|
||||
public virtual ViewEngineResult FindPartialView(ControllerContext controllerContext, string partialViewName, bool useCache)
|
||||
{
|
||||
return _wrappedEngine.FindPartialView(controllerContext, partialViewName, useCache);
|
||||
}
|
||||
|
||||
public virtual ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
|
||||
{
|
||||
return _wrappedEngine.FindView(controllerContext, viewName, masterName, useCache);
|
||||
}
|
||||
|
||||
public void ReleaseView(ControllerContext controllerContext, IView view)
|
||||
{
|
||||
_wrappedEngine.ReleaseView(controllerContext, view);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ namespace Umbraco.Web.Mvc
|
||||
/// A view engine to look into the template location specified in the config for the front-end/Rendering part of the cms,
|
||||
/// this includes paths to render partial macros and media item templates.
|
||||
/// </summary>
|
||||
public class RenderViewEngine : FixedRazorViewEngine
|
||||
public class RenderViewEngine : ReflectedFixedRazorViewEngine
|
||||
{
|
||||
|
||||
private readonly IEnumerable<string> _supplementedViewLocations = new[] { "/{0}.cshtml" };
|
||||
@@ -33,7 +33,7 @@ namespace Umbraco.Web.Mvc
|
||||
var replacePartialWithUmbracoFolder = _supplementedPartialViewLocations.ForEach(location => templateFolder + location);
|
||||
|
||||
//The Render view engine doesn't support Area's so make those blank
|
||||
ViewLocationFormats = replaceWithUmbracoFolder.ToArray();
|
||||
ViewLocationFormats = replaceWithUmbracoFolder.ToArray();
|
||||
PartialViewLocationFormats = replacePartialWithUmbracoFolder.ToArray();
|
||||
|
||||
AreaPartialViewLocationFormats = new string[] { };
|
||||
|
||||
@@ -78,6 +78,7 @@ namespace Umbraco.Web.Trees
|
||||
var proxiedRouteData = new HttpRouteData(
|
||||
controllerContext.RouteData.Route,
|
||||
new HttpRouteValueDictionary(new {action = "GetRootNode", controller = ControllerExtensions.GetControllerName(instance.GetType())}));
|
||||
|
||||
//create a proxied controller context
|
||||
var proxiedControllerContext = new HttpControllerContext(
|
||||
controllerContext.Configuration,
|
||||
@@ -86,10 +87,31 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
ControllerDescriptor = new HttpControllerDescriptor(controllerContext.ControllerDescriptor.Configuration, ControllerExtensions.GetControllerName(instance.GetType()), instance.GetType())
|
||||
};
|
||||
|
||||
|
||||
if (WebApiVersionCheck.WebApiVersion >= Version.Parse("5.0.0"))
|
||||
{
|
||||
//In WebApi2, this is required to be set:
|
||||
// proxiedControllerContext.RequestContext = controllerContext.RequestContext
|
||||
// but we need to do this with reflection because of codebase changes between version 4/5
|
||||
//NOTE: Use TypeHelper here since the reflection is cached
|
||||
var controllerContextRequestContext = TypeHelper.GetProperty(controllerContext.GetType(), "RequestContext").GetValue(controllerContext);
|
||||
TypeHelper.GetProperty(proxiedControllerContext.GetType(), "RequestContext").SetValue(proxiedControllerContext, controllerContextRequestContext);
|
||||
}
|
||||
|
||||
instance.ControllerContext = proxiedControllerContext;
|
||||
instance.Request = controllerContext.Request;
|
||||
|
||||
|
||||
if (WebApiVersionCheck.WebApiVersion >= Version.Parse("5.0.0"))
|
||||
{
|
||||
//now we can change the request context's route data to be the proxied route data - NOTE: we cannot do this directly above
|
||||
// because it will detect that the request context is different throw an exception. This is a change in webapi2 and we need to set
|
||||
// this with reflection due to codebase changes between version 4/5
|
||||
// instance.RequestContext.RouteData = proxiedRouteData;
|
||||
//NOTE: Use TypeHelper here since the reflection is cached
|
||||
var instanceRequestContext = TypeHelper.GetProperty(typeof(ApiController), "RequestContext").GetValue(instance);
|
||||
TypeHelper.GetProperty(instanceRequestContext.GetType(), "RouteData").SetValue(instanceRequestContext, proxiedRouteData);
|
||||
}
|
||||
|
||||
//invoke auth filters for this sub request
|
||||
var result = await instance.ControllerContext.InvokeAuthorizationFiltersForRequest();
|
||||
//if a result is returned it means they are unauthorized, just throw the response.
|
||||
|
||||
@@ -270,6 +270,8 @@
|
||||
<Compile Include="AreaRegistrationContextExtensions.cs" />
|
||||
<Compile Include="Models\LegacyConvertedNode.cs" />
|
||||
<Compile Include="Models\LegacyConvertedNodeProperty.cs" />
|
||||
<Compile Include="Mvc\MvcVersionCheck.cs" />
|
||||
<Compile Include="Mvc\ReflectedFixedRazorViewEngine.cs" />
|
||||
<Compile Include="Scheduling\BackgroundTaskRunner.cs" />
|
||||
<Compile Include="BatchedServerMessenger.cs" />
|
||||
<Compile Include="CacheHelperExtensions.cs" />
|
||||
@@ -809,6 +811,7 @@
|
||||
<Compile Include="WebApi\HttpRequestMessageExtensions.cs" />
|
||||
<Compile Include="WebApi\JsonCamelCaseFormatter.cs" />
|
||||
<Compile Include="WebApi\MemberAuthorizeAttribute.cs" />
|
||||
<Compile Include="WebApi\MvcVersionCheck.cs" />
|
||||
<Compile Include="WebApi\NamespaceHttpControllerSelector.cs" />
|
||||
<Compile Include="WebApi\UmbracoApiController.cs" />
|
||||
<Compile Include="WebApi\UmbracoApiControllerResolver.cs" />
|
||||
|
||||
10
src/Umbraco.Web/WebApi/MvcVersionCheck.cs
Normal file
10
src/Umbraco.Web/WebApi/MvcVersionCheck.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Umbraco.Web.WebApi
|
||||
{
|
||||
internal class WebApiVersionCheck
|
||||
{
|
||||
public static System.Version WebApiVersion
|
||||
{
|
||||
get { return typeof(System.Web.Http.ApiController).Assembly.GetName().Version; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@
|
||||
<host factoryType="umbraco.MacroEngines.RazorUmbracoFactory, umbraco.MacroEngines"/>
|
||||
<pages pageBaseType="umbraco.MacroEngines.DynamicNodeContext">
|
||||
<namespaces>
|
||||
<add namespace="Microsoft.Web.Helpers" />
|
||||
<add namespace="umbraco" />
|
||||
<add namespace="Examine" />
|
||||
</namespaces>
|
||||
|
||||
Reference in New Issue
Block a user