ASP.NET Web Forms: No 'Access-Control-Allow-Origin' header is present on the requested resource
<p>I know that similar questions have been asked but I tried almost all of them and none of them worked. </p>

<p>I need to simply allow a separate website (mywebsite.com) to access the Web API Methods of another web service (myserver.com) (coded on ASP.NET Web API and Hosted on azure)</p>

<p><strong>Server code:</strong></p>

<pre><code>public class MyController : ApiController
{
     [EnableCors(origins: "http://mywebsite.com", headers: "*", methods: "*")]
     [Route("api/sendrequest")]
     [HttpPost]
     public IHttpActionResult SendRequest()
     {
          string response = "You made it to the server!";

          return Ok(new { response });
     }
}
</code></pre>

<p><strong>Client side Ajax request:</strong></p>

<pre><code>function send_data() {

    var values = "Hello from Client";

    $.ajax({
        url: "https://myserver.com/api/mycontroller/sendrequest",
        type: "POST",
        data: values,
        success: function (response) {
            alert(response);
            console.log(response);
        },
        error: function (jqXHR, textStatus, errorThrown) {
            console.log(textStatus, errorThrown);
            alert("error");
        }

    });
}
</code></pre>

<p>Even though I've allowed this specific website to communicate with the server, it still returns me this error in the console:</p>

<blockquote>
  <p>XMLHttpRequest cannot load
  <a href="https://myserver.com/api/mycontroller/sendrequest" rel="nofollow">https://myserver.com/api/mycontroller/sendrequest</a>. </p>
  
  <p><strong>No 'Access-Control-Allow-Origin' header is present on the requested
  resource. Origin '<a href="http://mywebsite.com" rel="nofollow">http://mywebsite.com</a>' is therefore not allowed
  access. The response had HTTP status code 500.</strong></p>
</blockquote>

<p>What am I doing wrong here? Should I include any additional details in the request header?</p>