0

I am working on WebApi and CORS is enabled for WebAPI.config level but it is not enabled for MVC Controller? I am not asking about .Net CORE!

1
  • I don't think so @Mikev, look at the tags, he doesn't ask for .NET Core specifically Commented Mar 19, 2019 at 14:31

1 Answer 1

0

Check out https://learn.microsoft.com/en-us/aspnet/web-api/overview/security/enabling-cross-origin-requests-in-web-api

It says:

using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Cors;

namespace WebService.Controllers
{
    [EnableCors(origins: "http://mywebclient.azurewebsites.net", headers: "*", methods: "*")]
    public class TestController : ApiController
    {
        // Controller methods not shown...
    }
}

So use the EnableCors attribute. Good luck.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.