Base solution for your next web application
Open Closed

Can't access API from external domain .NetZero 4.0.0 #4079


User avatar
0
tactuumadmin created

I am having issues accessing my API from an external site and can't think why it's happening. From Postman, I am able to access everything without any issues, but when trying to access the API directly, I receive the same message every time:

405: Method Not Allowed (referring to the OPTIONS pre-flight request sent).

I can't seem to get any further than this regardless of what setup I do to either the source project or the .NetZero project. Am I missing a key element of the setup that will enable this feature to work as expected?

Many thanks, Kenny


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @TactuumAdmin,

    By "when trying to access the API directly", do you mean an external web application ? If so, probably you need to enable CORS in your web api.

  • User Avatar
    0
    tactuumadmin created

    @ismcagdas Thank you for your response.

    Is there something beyond adding the CORS information to the customHeaders section of the web.config that needs to be done in order to enable CORS for the Web API? There doesn't appear to be any specific documentation for this on the .NetZero website. It is mentioned for the projects that use .Net Core, however we are using the MVC5 with JQuery version and there doesn't appear to be anything (that I can find) to specify any specific configuration requirements.

    Many thanks, Kenny

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @TactuumAdmin,

    This is not specific to AspNet Zero actually. Please refer to this post #808@1366e8c2-16f3-4541-9def-894cd9de774b.