Configure Swagger to work with DotNetNuke (DNN)

263 views Asked by At

I am trying to use Swagger with an API I created in DotNetNuke, but I can't get it to work.

I have installed Swashbuckle and all its dependencies, but I cannot access the swagger ui endpoint. I believe that DotNetNuke is messing with the routing, and that is causing the problem.

I have a RouteMapper that is implemented like this:

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

Any ideas on how this problem can be fixed, in order to be able to access the swagger's endpoints?

1

There are 1 answers

2
Mitchel Sellers On

Within the DNN Platform under SEO > URL Management > Expressions there is a setting Ignore URL Regular Expression this is a Regular Expression that tells the Friendly URL system to completely ignore the pattern. You will need to add Swagger to this.

NOTE: This is something that in general does NOT play well with DNN, so your results might be a bit "iffy"