Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpConfiguration method EnableCors not found

Enabled CORS on one project, trying to do it on another existing project, however the "EnableCors" method cannot be found in during compilation:

public static class WebApiConfig
{
    public static void Register(HttpConfiguration config)
    {
        config.EnableCors();

The exact compile fail error message is

'HttpConfiguration' does not contain a definition for 'EnableCors' and no extension method 'EnableCors' accepting a first argument of type 'HttpConfiguration' could be found (are you missing a using directive or an assembly reference)

I've done the same thing in this project as I have the other project:

<package id="Microsoft.AspNet.Cors" version="5.2.3" targetFramework="net451" />
<package id="Microsoft.AspNet.WebApi.Cors" version="5.2.3" targetFramework="net451" />

This project has odata in it though...I'm not sure if that's the major difference making it fail.

Any ideas? I've also tried

Update-Package -reinstall Microsoft.AspNet.WebApi.Cors 
like image 863
McNinja Avatar asked Aug 10 '17 20:08

McNinja


1 Answers

I had to reinstall all the packages - THEN the compile error went away.

Weird. I had built & cleaned the project several times.

like image 65
McNinja Avatar answered Sep 28 '22 07:09

McNinja