Skip to content

Instantly share code, notes, and snippets.

@nul800sebastiaan
Last active August 29, 2015 14:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nul800sebastiaan/db84218fcf07276416ed to your computer and use it in GitHub Desktop.
Save nul800sebastiaan/db84218fcf07276416ed to your computer and use it in GitHub Desktop.
Add custom webapi route
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 });
}
}
}
@schrepel
Copy link

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:.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment