I have a pre-existing Sitecore 9 instance that houses an existing website.
I have created a new solution, with a new web project, and am attempting to install this project into the existing Sitecore 9 instance. This new web project simply exposes a handful of Controller Actions that return JSON.
I have decided to create this new project using MVC Areas. Currently, the project is empty except for an Area Registration and a single controller with a single action.
public class MyApiAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "MyApi";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.Namespaces.Add("MyApi.Web.Areas.MyApi.Controllers");
var aboutRoute = context.MapRoute(
"MyApi_about",
"myapi/about/version",
new { controller = "About", action = "Version"},
new[] {"MyApi.Web.Areas.MyApi.Controllers"});
aboutRoute.RouteHandler = new Sitecore.Mvc.Routing.RouteHandlerWrapper(aboutRoute.RouteHandler);
}
}
This project has the following nuget references:
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net462" />
<package id="Microsoft.AspNet.Razor" version="3.2.4" targetFramework="net462" />
<package id="Microsoft.AspNet.WebPages" version="3.2.4" targetFramework="net462" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net462" />
<package id="Sitecore.Mvc.NoReferences" version="9.0.171219" targetFramework="net462" developmentDependency="true" />
And the AboutController
referenced above simply returns a JSON Response with the assembly info version number.
When I compile this project, I get a single .dll file. I copy this .dll file to my running Sitecore instance and restart it within IIS. When I go to check my logs, however, I do not see where the "MyApi" area is registered. What else must be done to register a custom area within Sitecore?