skip to Main Content

I had a website running DotNetNuke 9.0, after updating to 9.2 suddenly my API starts to return 404, nothing on the API changed, just the dnn framework.

I have tried to add and clear cache, and restart the application, nothing worked so far.

Also checked the SEO URL Rewrite options and this is what I have:

Do Not Rewrite URL Regular Expression

/DesktopModules/|/Providers/|/LinkClick.aspx|/profilepic.ashx|
/DnnImageHandler.ashx|/__browserLink/|/API/|/WebAPI/

Do Not Redirect URL Regular Expression

(.axd)|/Rss.aspx|/SiteMap.aspx|.ashx|/LinkClick.aspx|/Providers/
|/DesktopModules/|ctl=MobilePreview|/ctl/MobilePreview|/API/|/WebAPI/

Currently I have the following RouteMapper:

using System;
using DotNetNuke.Web.Api;

namespace WebAPI
{
    public class RouteMapper : IServiceRouteMapper
    {
        public void RegisterRoutes(IMapRoute mapRouteManager)
        {
            mapRouteManager.MapHttpRoute("WebAPI", "default", "{controller}/{action}", new[] { "WebAPI" });
        }
    }
}

And an example of my API Controller

using System;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using DotNetNuke.Web.Api;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Users;

namespace WebAPI
{
    public class PingController : DnnApiController
    {
        [AllowAnonymous]
        [HttpGet]
        public HttpResponseMessage Send()
        {
            var portalId = PortalController.GetEffectivePortalId(PortalSettings.PortalId);
            UserInfo user = PortalSettings.UserInfo;

            return Request.CreateResponse(HttpStatusCode.OK, "Ping on portal: " + PortalSettings.PortalId + " You are user: " + user.Username);
        }

        //Could be  [DnnAuthorize(StaticRoles = "Registered Users" )]
        [DnnAuthorize]
        [HttpGet]
        public HttpResponseMessage SendAuth()
        {
            var portalId = PortalController.GetEffectivePortalId(PortalSettings.PortalId);
            UserInfo user = PortalSettings.UserInfo;

            return Request.CreateResponse(HttpStatusCode.OK, "Ping on portal: " + PortalSettings.PortalId + " You are user: " + user.Username);
        }
    }
}

Is this correct? What else can I check?

2

Answers


  1. Have you checked the Event Log to see if there are errors?

    The 9.0 to 9.2 upgrade may have exposed you to some deprecated stuff that was removed in the 9.2 release. Checking for errors is possibly a quick way to see if that’s what happened.

    Login or Signup to reply.
  2. I was struggling with this exact same problem this week for a new open source community website I was launching for #oqtane ( http://www.oqtane.org ). For me the the problem ended up being related to a missing reference in my web.config file. I am not sure how the reference was removed ( probably by uninstalling a DNN module ) but the end result was that routing was no longer enabled which caused the jQuery service calls to the WebApi methods to fail with 404 errors. You should check your web.config file in the Modules area to ensure that the UrlRoutingModule is included:

    <modules>
      ...
      <remove name="UrlRoutingModule-4.0" />
      <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="managedHandler" />
      ...
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search