Asp.net MVC 5.x Session Expires - AJAX Request

Using the following code example https://github.com/leebrandt/okta-aspnet-mvc-authz-example

Scenarios

  1. (Works perfectly) - If a user sits on the page with out any activity for more than an hour the login session expires (.AspNet.Cookies) and when the user clicks to navigate to another page a status code 302 => okta auth occurs to authorize the user again “/oauth2/default/v1/authorize”
  2. (Fails - Cors) - If a user sits on the page with out any activity for more than an hour the login session expires (.AspNet.Cookies) and when the user clicks on a button to save some work via AJAX call a CORS error occurs because AJAX request has been blocked by the CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Do have any suggestions on how to fix this issue?

Have you added the domain your app is hosted on as a trusted domain for CORS in Okta?

Yes I’ve added my local dev to the Trusted Origins under the security > api section

What’s the request path that is resulting in the CORS error? Is it still the same authorize endpoint?

Typo in my CORS

Thanks