• Login
  • Register

DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.


You are not authorized to post a reply.

New Member

New Member


    Is there a way to enable CORS on DNN. I have few angular apps that could use DNN for Authentication/Authorisation but I cant seem to make it work.

    I tried setting it in web.cofig via customHeaders but that did not work.


    Is there away to enable CORS on DNN (9.3 in my case)?



    Basic Member

    Basic Member

      The short answer is yes, there is a way to enable CORS.  However, it is really a loaded question.  And, it is typically not a good idea to enable CORS anyway, but rather make sure the proper security is in place for API calls.  That said, here are some ideas for you.

      If you are on IIS7, you can merge this with your web.config:

      For IIS6:
      1)  Open Internet Information Service (IIS) Manager
      2)  Right click the site you want to enable CORS for and go to Properties
      3)  Change to the HTTP Headers tab
      4)  In the Custom HTTP headers section, click Add
      5)  Enter Access-Control-Allow-Origin as the header name
      6)  Enter * as the header value
      7)  Click Ok twice

      Lastly...you may want to try this.  In each action method which requires CORS access, add the Access-Control-Allow-Origin header:

      var response = this.Request.CreateResponse(HttpStatusCode.OK, new MyResponse { Id = 10 });
      response.Headers.Add("Access-Control-Allow-Origin", "*");
      return response;

      David Poindexter
      Corporate Website  |  Facebook Page  |  Twitter Page

      Creator of:

      Basic Member

      Basic Member

        To add on to David's caution, using Access-Control-Allow-Origin: * disables any protections that CORS should provide.  Rather, you should use that header to indicate the specific origin that you are expecting.  If there are multiple origins that you need to support, you'll need to set the origin dynamically, which would be similar to David's last example.

        response.Headers.Add("Access-Control-Allow-Origin", "https://another.website.example.com");
        DNN partner specializing in custom, enterprise DNN development https://engagesoftware.com/showcase
        You are not authorized to post a reply.

        These Forums are dedicated to discussion of DNN Platform.

        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.

        Would you like to help us?

        Awesome! Simply post in the forums using the link below and we'll get you started.

        Get Involved