Cors requests and MVC5
<p>So I have a view on a controller ...</p>

<pre><code>[AllowAnonymous]
[Route("MyView")]
public ActionResult MyView()
{
    // first attempt at solving problem
    Response.AddHeader("Access-Control-Allow-Origin", "*");
    Response.AddHeader("Access-Control-Allow-Headers", "*");
    Response.AddHeader("Access-Control-Allow-Methods", "*");

    return PartialView();
}
</code></pre>

<p>I tried adding this attribute (2nd attempt) ...</p>

<pre><code>public class AllowCors : ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        filterContext.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Origin", "*");
        filterContext.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Headers", "*");
        filterContext.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Methods", "*");
        base.OnActionExecuting(filterContext);
    }
}
</code></pre>

<p>As im using owin to initialise my app I figured this might work (3rd attempt) ...</p>

<pre><code>app.Use((context, next) =&gt;
{
    if (context.Request.Method == "OPTIONS")
    {
        context.Response.StatusCode = 200;
        context.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
        context.Response.Headers.Add("Access-Control-Allow-Headers", new[] { "*" });
        context.Response.Headers.Add("Access-Control-Allow-Methods", new[] { "*" });
        return context.Response.WriteAsync("handled");
    }

    return next.Invoke();
}).UseStageMarker(PipelineStage.PreHandlerExecute);
</code></pre>

<p>The problem is that if I just straight up ask for it by putting the url in the browser I get the right headers ...</p>

<pre><code>Access-Control-Allow-Headers:*
Access-Control-Allow-Methods:*
Access-Control-Allow-Origin:*
</code></pre>

<p>... moving over in to postman to test this, when I issue an OPTIONS call to the same URL I get this in the headers ...</p>

<pre><code>Allow: OPTIONS, TRACE, GET, HEAD, POST
</code></pre>

<p>... so how do I get MVC to respond correctly to the OPTIONS http verb so that I can use this view outside the domain of the site?</p>

<p><strong>EDIT</strong></p>

<p>it's worth noting that I have looked around already and found all these and many more ...</p>

<p><a href="https://stackoverflow.com/questions/24352519/the-requested-resource-does-not-support-http-method-options?lq=1">The requested resource does not support http method &#39;OPTIONS&#39;.?</a></p>

<p><a href="https://stackoverflow.com/questions/1099787/jquery-ajax-post-sending-options-as-request-method-in-firefox">jQuery $.ajax(), $.post sending &quot;OPTIONS&quot; as REQUEST_METHOD in Firefox</a></p>

<p><a href="https://stackoverflow.com/questions/21783079/ajax-in-chrome-sending-options-instead-of-get-post-put-delete">AJAX in Chrome sending OPTIONS instead of GET/POST/PUT/DELETE?</a></p>

<p><a href="https://stackoverflow.com/questions/16705366/why-does-this-jquery-ajax-put-work-in-chrome-but-not-ff">Why does this jQuery AJAX PUT work in Chrome but not FF</a></p>

<p><a href="https://stackoverflow.com/questions/19095777/how-to-support-http-options-verb-in-asp-net-mvc-webapi-application">How to support HTTP OPTIONS verb in ASP.NET MVC/WebAPI application</a></p>

<p>... i'm also very familiar with using CORS and making CORS requests in to WebAPI, but for some reason I can't seem to make a CORS request in to MVC without getting this seemingly "dummy" response back.</p>

<p>I think what I need is a means to override / replace the MVC default behaviour to this HttpVerb based request to allow me to embed views in a remote site.</p>