Azure B2C Unified sign up with Page UI customization

2016, Apr 13    

When crafting a new Unified sign-up or sign-in page policy in the Azure Portal I managed to get this error

#error=server_error&error_description=AADB2C90001: The server hosting resource 'https://meetr.azurewebsites.net/account/signinorsignup' is not enabled for CORS requests. Ensure that the 'Access-Control-Allow-Origin' header has been configured.<br /> Correlation ID: 613d1479-d146-4b89-abb8-3264730f5991<br /> Timestamp: 2016-04-13 18:33:30Z<br />

Of course, i’d been a bit quick off the mark and not yet changed my Asp.net website to accept Cross Origin Requests.

Here’s what you’ll need to add to your unified Sign In page to fix the error
<br /> Response.AppendHeader("Access-Control-Allow-Origin", "https://login.microsoftonline.com");<br />

Code wise, here’s how the Controller Action and View look;

public ActionResult SignInOrSignUp()
    {
      Response.AppendHeader("Access-Control-Allow-Origin", "https://login.microsoftonline.com");
      return View();
    }
@{
    ViewBag.Title = "SignInOrSignUp";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>SignInOrSignUp</h2>

<p>This is our own experience for sign in/up</p>

<div id="api"></div>