I have developed AngularJS application along with ASP.NET WebAPI 2, application structure should be website layer, data access layer (entity FW) , WebApi layer
every think works fine.
The problem is my website is running on
Normally you should do this with configuring CORS indeed by adding the configuration to either your WebAPI configuration or web.config.
For the WebAPI configuration you should specify the following:
config.EnableCors(new EnableCorsAttribute("*", "*", "*"));
web.config it should look like this:
<system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*"/> </customHeaders> </httpProtocol> <system.webServer>
Of course, this allows all origins, so you have to change it to
localhost:8080 in your situation. Keep in mind, different ports are different origins, so specifying only
localhost isn't sufficient, the port should be added also!
When moving to production, you should configure the correct CORS locations via the build server of course, but that's a completely different topic.