Learn More





Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesServices Framework problemsServices Framework problems
New Post
9/3/2014 5:32 PM
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!

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>
        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)
            return routes.ToArray();

<script type="text/javascript">

    var servicesFramework = $.ServicesFramework(<%=ModuleId %>);

    var members = null;
        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) {


namespace EUSPBA.Registration
    public partial class view2 : PortalModuleBase
        protected override void (EventArgs e)
            base. (e);

New Post
9/3/2014 8:53 PM

Regarding question #1 - I've had some problems getting the SupportedModules attribute to work . . . until after trial and error I realized that you should be passing in the module name (as registered in the DNN manifest) not it's namespace. Is EUSBPA.Registration the module name as well as its namespace? For example in my recent Forge project, DNN NewsTicker:

namespace WESNet.DNN.Modules.NewsTicker.Services
    public class NewsTickerServicesController : DnnApiController

 Regarding Question #2 - Your override of OnInit and call to ServicesFramework.Instance.RequestAjaxAntiForgerySupport(); looks to be correct as does your javascript in view.ascx (although I would prefer to wrap this code in a function called on $(document).ready) provided that "EUSBPA" is the name of the module's folder under the DesktopModules folder.

You do not show your code for implementing the RegisterRoutes method of the IServiceRouteMapper interface so am wondering if that may be part of the problem.

Also, shouldn't the Get() method of your DnnApiController return a HttpResponseMessage object rather than IEnumerable<string>?

Here's a short sample from one of the services controller methods of my Forge ePrayer module:


        [DnnAuthorize(StaticRoles = "Registered Users")]
        public HttpResponseMessage GetSuggestions(int groupId, string displayName)
                var names = (from DotNetNuke.Entities.Users.UserInfo user in GetUsers(groupId, displayName.Trim(), 0, 10)
                             select new { label = user.DisplayName, value = user.DisplayName, userId = user.UserID })

                return Request.CreateResponse(HttpStatusCode.OK, names);
            catch (Exception exc)
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc);

Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
New Post
9/4/2014 9:17 AM
William -- thanks for your reply.

The service works if I remove the SupportedModules attribute, so the routing is fine as far as I can tell. I looked at the SupportedModules source code and it does use the DesktopModules.Name field. Nnote that 'Get' is just some dummy code to return something to the client).

setModuleHeaders does not appear to work in this version of DNN. One additional thing I noticed: servicesFramework.getTabId returns -1 instead of the actual Tabid; not sure why.

I'll just have to code around this.....
New Post
9/5/2014 12:48 PM
In case anybody else runs into this, here's what I did:

In the ajax call I manually set the headers:

headers: {
'ModuleId': @Dnn.Module.ModuleID,
'TabId': @Dnn.Module.TabID,
'RequestVerificationToken': servicesFramework.getAntiForgeryValue()

Now in the Controller, ActiveModule is now populated. So now I can get the module's Settings. All is good.
New Post
9/26/2014 9:49 AM

Hi Jonathan,

While preparing a module sample for a friend I encountered the same problem. After two days of research (sic), I have found why [SupportedModules("...")] attribute and a few others do not works!

The problem is NOT related to DNN but to me and... YOU! :-) We have both forgoten to enclose our Javascript code with a "document ready" function. Because $.ServiceFrameworks() is a jQuery plugin, we have to wait until the document is ready and the plugin is initialized.

If you enclose your code from the view.ascx form everything works like a charm:

$(document).ready(function() {
var servicesFramework = $.ServicesFramework(<%=ModuleId %>);


We (team members) are Humans offering their knowledge, their work and their spare time FOR FREE to benefit the community. It would be so particularly appreciated that your messages begin with "Hello" and end with "Thank you" or any other form of politeness. Ask yourself what your reaction would be, if you were approached by me (a total stranger) on the street to ask you something without saying "Hello" nor "Thank you"? After several years of services dedicated to the community, I begin to be tired to read requests without any form of politeness.
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesServices Framework problemsServices Framework problems

These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
Try Evoq
For Free
Start Free Trial
a Demo
See Evoq Live
Need More Information?