DEV Community

serhanyilmaz
serhanyilmaz

Posted on

ASP.NET CORE REACT APP: System.InvalidOperationException: SPA default page middleware failed to return default page /index.html

UI PROJECT ENVIRONMENT: ASP.NET CORE MVC
UI PROJECT TYPE: ASP.NET CORE + REACT APPLICATION
ERROR NAME/ FORUM TITLE:
ASP.NET CORE MVC REACT PROJECT: System.InvalidOperationException: SPA default page middleware failed to return default page '/index.html' because it was not found and no other middleware was processing the request
ERROR DETAIL:
I have a React project created with ASP.NET CORE MVC template.
This React UI project takes data from a separate ASP.NET CORE MVC based WEB API project and projects customer data to the screen.
Authentication, Authorization and Data retrieval operations are provided via API.
While connecting to a user UI page, LDAP authorizations are checked from the relevant API. UI page opens if LDAP authorization is available.
If the user does not have LDAP authorization, the screen will display You Are Not Authorized.
These React-based Web UI and Web API pages run on IIS on Windows server.
In addition, both UI and API are installed on three servers named S1, S2 and S3 and work over Load Balancer.
90% of users have direct access to the relevant UI. Some can log in from S1, some from S2, some from S3 server with Load Balancer management.
However, some users encounter the following error when opening the relevant UI page.
We detected this error on Dynatrace.
Error :
REACT The SPA default page middleware could not return the default page '/index.html' because it was not found, and no other middleware handled the request. Your application is running in Production mode, so make sure it has been published, or that you have built your SPA manually. Alternatively you may wish to switch to the Development environment.

We couldn't figure out why some users are getting this error even though most users access the same page.
What do you think could be the reasons for the access problem?

Top comments (0)