How do I enable the CORS option in asp.net
WebApi? I installed the package Microsoft.AspNet.WebApi.Cors
from nuget for CORS support. However, I am getting an error stating that IAppBuilder
does not contain definition for app.useCors
?
Asked
Active
Viewed 2,128 times
4

SouthShoreAK
- 4,176
- 2
- 26
- 48

Ali Nafees
- 185
- 1
- 1
- 7
-
can you share the code you have tried? – awh112 Feb 01 '17 at 18:08
-
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); – Ali Nafees Feb 01 '17 at 18:54
-
Have you tried everything in this answer? http://stackoverflow.com/questions/20079813/how-to-make-cors-authentication-in-webapi-2 – awh112 Feb 01 '17 at 19:00
-
yes but app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); says IaapBuilder could not found definition for UseCors – Ali Nafees Feb 01 '17 at 19:17
-
Have you installed the `Microsoft.AspNet.WebApi.OwinSelfHost` and `Microsoft.Owin.Cors` NuGet packages? – awh112 Feb 01 '17 at 19:31
-
thank you, I installed Microsoft.Owin.Cors and now its working fine – Ali Nafees Feb 01 '17 at 19:59
-
Happy to help! I've added the above comment as an answer to help others find it in the future. – awh112 Feb 01 '17 at 20:10
1 Answers
9
Make sure you have installed the Microsoft.AspNet.WebApi.OwinSelfHost
and Microsoft.Owin.Cors
NuGet packages.

awh112
- 1,466
- 4
- 22
- 34