How to Create a Custom Error Page in Azure AD B2C

2019-08-10 23:16发布

问题:

When using custom policies, how can I specify the error page for a <UserJourney>? Based on the values in the TFP base xml file, I would have thought it would be <RecoveryUri> but that is not working.

<ContentDefinition Id="api.signuporsignin-ext-local">
    <!-- <LoadUri>~/tenant/default/unified.cshtml</LoadUri> -->
    <LoadUri>https://localhost:44377/</LoadUri>
    <!-- <RecoveryUri>~/common/default_page_error.html</RecoveryUri> -->
    <RecoveryUri>https://localhost:44377/Home/Error</RecoveryUri>
    <DataUri>urn:com:microsoft:aad:b2c:elements:unifiedssp:1.0.0</DataUri>
    <Metadata>
        <Item Key="DisplayName">Signin and Signup</Item>
    </Metadata>
</ContentDefinition>

Current Result:

回答1:

You would want to update the api.error content definition:

<!-- This content definition is to render an error page that displays unhandled errors. -->
<ContentDefinition Id="api.error">
  <LoadUri>~/tenant/default/exception.cshtml</LoadUri>
  <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
  <DataUri>urn:com:microsoft:aad:b2c:elements:globalexception:1.1.0</DataUri>
  <Metadata>
    <Item Key="DisplayName">Error page</Item>
  </Metadata>
</ContentDefinition>