I'm having the same error message as the original poster had ("Unable to locate a controller for..."), but I can't figure out what to do exactly. Here are my 2 classes. Anyone see my issues? I'm trying to add this to an existing c# 4.0 project. I feel like I'm really close.
//////////////////////////// WelcomeController.cs
using System;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using DotNetNuke.Web.Api;
namespace RainstormTech.Modules.Storm
{
public class WelcomeController : DnnApiController
{
[AllowAnonymous]
[HttpGet]
public HttpResponseMessage HelloWorld()
{
return Request.CreateResponse(HttpStatusCode.OK, "The time is: " + DateTime.Now.ToLongTimeString());
}
}
}
////////////////////////////////////////////// StormRouteMapper.cs
using DotNetNuke.Web.Api;
namespace RainstormTech.Modules.Storm
{
public class StormRouteMapper : IServiceRouteMapper
{
public void RegisterRoutes(IMapRoute mapRouteManager)
{
mapRouteManager.MapHttpRoute("Storm", "default", "{controller}/{action}", new[] { "RainstormTech.Modules.Storm" });
}
}
}
//////////////// More info
I even debugged it locally and while stepping through it, I found that my controller didn't exist if the dictionary of DescriptorCache as in the following Core code:
var matches = new List();
foreach (string ns in namespaces)
{
string fullName = GetFullName(controllerName, ns);
HttpControllerDescriptor descriptor;
if (DescriptorCache.TryGetValue(fullName, out descriptor)) // never matches here
{
matches.Add(descriptor);
}
}
Hopefully someone knows what I need to do. Thanks.