<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D54z00008jWgUgCAKOkta Classic EngineAuthenticationAnswered2023-11-01T19:43:09.000Z2023-02-05T00:47:39.000Z2023-02-06T17:29:31.000Z

KechengL.63420 (Customer) asked a question.

How to redirect to a message page when the user does not exist in the okta application in .Net 6 Blazor Server app

The sample code I user is from https://github.com/okta/samples-aspnetcore.

the controller

    [HttpPost]

    [ValidateAntiForgeryToken]

    public IActionResult SignIn([FromForm] string sessionToken)

    {

      if (!HttpContext.User.Identity.IsAuthenticated)

      {

        var properties = new AuthenticationProperties();

        properties.Items.Add("sessionToken", sessionToken);

        properties.RedirectUri = "/Home/";

        return Challenge(properties, OktaDefaults.MvcAuthenticationScheme);

      }

 

      return RedirectToAction("Index", "Home");

    }

the program.cs

builder.Services.AddAuthentication(options =>

  {

    options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;

    options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;

    options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;

  })

  .AddCookie(options =>

  {

    options.LoginPath = new PathString("/Account/SignIn");

  })

  .AddOktaMvc(new OktaMvcOptions

  {

    // Replace these values with your Okta configuration

    OktaDomain = builder.Configuration.GetValue<string>("Okta:OktaDomain"),

    ClientId = builder.Configuration.GetValue<string>("Okta:ClientId"),

    ClientSecret = builder.Configuration.GetValue<string>("Okta:ClientSecret"),

    AuthorizationServerId = builder.Configuration.GetValue<string>("Okta:AuthorizationServerId"),

    Scope = new List<string> { "openid", "profile", "email" },

  });

 

Thanks

 


  • Hi @KechengL.63420 (Customer)​ , Thank you for reaching out to the Okta Community!

     

    The following article might help your use case:

    https://help.okta.com/en-us/Content/Topics/Settings/settings-configure-app-error-page.htm

     

    My advice would also be to reach out to the dedicated Developer Forum devforum.okta.com to take advantage of their expertise.  

    While we'll do our best to answer all of your questions here, this medium is more inclined towards Okta core products and features. 

     

     

    If my answer helped, remember to mark it as best to increase its visibility for other members of the Okta Community who might have the same questions as you. 

     

    Hope my answer helps! 

    --------------------------------

    Community members help others by clicking Like or Select as Best on responses. Try it today.

    Expand Post
  • KechengL.63420 (Customer)

    Thank you so much Mihai for quick response.

    I use OpenID Connect and Web Application to create an okta application, but I could not find "App Embed Link" section. in General tab.

    I use the following instructions to setup redirect error page, such as https://localhost:5001/OktaError. it does not work, it shows https://localhost:5001/authorization-code/callback and error is OpenIdConnectProtocolException: Message contains error: 'access_denied', error_description: 'User is not assigned to the client application.', error_uri: 'error_uri is null'.

     

    1. In the Admin Console, go to Customizations > Other.
    2. Scroll to the Application Access Error Page section, and then click Edit.

     

    The application is .net 6 Blazor server application

     

    Thanks

    Expand Post
This question is closed.
Loading
How to redirect to a message page when the user does not exist in the okta application in .Net 6 Blazor Server app