Last active
August 29, 2015 14:10
-
-
Save nul800sebastiaan/db84218fcf07276416ed to your computer and use it in GitHub Desktop.
Add custom webapi route
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using System.Web.Http; | |
using System.Web.Mvc; | |
using System.Web.Routing; | |
using Umbraco.Core; | |
namespace MyNamespace | |
{ | |
public class MyApplicationEventHandler : ApplicationEventHandler | |
{ | |
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) | |
{ | |
RouteTable.Routes.MapHttpRoute( | |
"MyCustomApiRoute", | |
"MyCustomApi/{controller}/{id}", new { id = UrlParameter.Optional }); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wondering if this also would solve our recent trouble where we have a rewrite rule in web.config to force all backoffice (localhost/umbraco/) calls use https://(localhost/umbraco/), but that's causing cross-domain errors in our custom Surface controllers (/umbraco/surface/GetProducts/) where we're trying to return JSON data. (We get "No 'Access-Control-Allow-Origin' header" errors from JSON because it's trying to cross domains between http: and https:.