I'm having 2 problems w/ the Web API (DNN 7.3.2):
1) [SupportedModules("module name as shown in DesktopModules table")] - this is not working; ajax calls keep getting 401/not authorized.
2) in the ajax call ( $.ajax({...}) ), beforeSend: servicesFramework.setModuleHeaders is not setting the ModuleId & TabId in the Headers.
Any ideas?? How can debug this to determine the real problem? Thanks!
Controller
using DotNetNuke.Security;
using DotNetNuke.Web.Api;
using System.Collections.Generic;
using System.Web.Http;
using System.Web.Routing;
namespace EUSPBA.API.Controllers
{
[DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.Anonymous)]
[SupportedModules("EUSPBA.Registration")] //this does not work if enabled
public class RegistrationController : DnnApiController
{
// GET api/<controller>
[HttpGet]
[AllowAnonymous]
public IEnumerable<string> Get()
{
if (ActiveModule != null)
{
var i = ActiveModule.ModuleID;
}
List<string> routes = new List<string>();
foreach (RouteBase item in RouteTable.Routes)
{
Route route = item as Route;
if (route != null)
routes.Add(route.Url);
}
return routes.ToArray();
}
}
}
view.ascx
<script type="text/javascript">
var servicesFramework = $.ServicesFramework(<%=ModuleId %>);
var members = null;
$.ajax({
type: "GET",
dataType: "json",
url: servicesFramework.getServiceRoot("EUSPBA") + "registration/get",
async: false,
//headers: {"ModuleId": servicesFramework.getModuleId()}, //this works if enabled
beforeSend: servicesFramework.setModuleHeaders, //does not work
success: function (data) {
members = data;
},
error: function (error) {
error);
}
});
</script>
view.ascx.cs
namespace EUSPBA.Registration
{
public partial class view2 : PortalModuleBase
{
protected override void (EventArgs e)
{
base. (e);
ServicesFramework.Instance.RequestAjaxAntiForgerySupport();
}
}
}