Fixes up the starter kit installer in the back office with it's legacy implementation. Adds some handy methods for webapi routing for areas.

This commit is contained in:
Shannon
2014-03-05 22:42:51 +11:00
parent 24cc417395
commit feab2de260
23 changed files with 170 additions and 315 deletions

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Runtime.Remoting.Contexts;
using System.Threading;
using System.Threading.Tasks;
@@ -113,21 +112,4 @@ namespace Umbraco.Web.WebApi
// controllerContext.Configuration.Formatters.Add(new AngularJsonMediaTypeFormatter());
//}
}
/// <summary>
/// Applying this attribute to any webapi controller will ensure that it only contains one json formatter compatible with the angular json vulnerability prevention.
/// </summary>
public class AngularJsonOnlyConfigurationAttribute : Attribute, IControllerConfiguration
{
public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor)
{
//remove all json/xml formatters then add our custom one
var toRemove = controllerSettings.Formatters.Where(t => (t is JsonMediaTypeFormatter) || (t is XmlMediaTypeFormatter)).ToList();
foreach (var r in toRemove)
{
controllerSettings.Formatters.Remove(r);
}
controllerSettings.Formatters.Add(new AngularJsonMediaTypeFormatter());
}
}
}