# Authentication Failure Handling in .NET
In my recent blog post titled ".NET Authentication and Authorization," I discussed the configuration and implementation of authentication and authorization in a .NET application. However, I failed to address an important aspect: handling authentication failures.
By default, the authentication configuration in .NET uses a cookie policy. When an authentication failure occurs, it responds with a 302 status code and redirects to the `/Account/Login` page. This poses a problem when the frontend and backend of the application are separated, as the redirect will not point to the correct address.
For instance, let's assume the frontend app is hosted at `localhost:8800` and the backend app at `localhost:9900`. If an authentication failure occurs during a frontend API request, the response will contain a 302 status code with the location set to `localhost:9900/Account/Login`. The frontend, using HTTP APIs like `fetch` or `Axios`, will automatically fol...--GPT 4