Enable CROS for azure

http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api

No need to add proxy in We.config

<!–<system.net>
<defaultProxy useDefaultCredentials=”true”>
<proxy bypassonlocal=”True” usesystemdefault=”True” />
</defaultProxy>
</system.net>–>

Add following code to enable Cors in WebApiConfig.cs

public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// New code for enable cross-origin resource sharing (CORS)
config.EnableCors();

Add attribute EnableCors in Controller.cs

[EnableCors(origins: “http://ashuthinkswebsite.azurewebsites.net&#8221;, headers: “*”, methods: “*”)]
public class ContactsController : ApiController

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s