HTTP ERROR 414

Bhassan 0 Reputation points
2025-04-07T09:27:08.4666667+00:00

Hi Dears,

I need your help with fixing this "HTTP ERROR 414" "URI too long", I have hosted a web app on azure web application (Linux based container), the application developed with asp.net core mvc, now I published but the login page doesn't open it shows the HTTP ERROR 414 , would you please tell me wht is the issue and how can we fixed? as you know azure web app is Paas I can't change anything on the configuration.

Thanks in advance,

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,932 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Siva Nair 2,340 Reputation points Microsoft External Staff Moderator
    2025-04-09T02:21:10.1266667+00:00

    Hi Bhassan,

    Thanks for Confirming. The HTTP ERROR 414 you're seeing on the login page is likely caused by an overly long request URL or headers and in our case, since we're using custom ASP.NET Core authentication (not Azure AD), this is most likely due to one of the following:

    1. ASP.NET Core uses cookie-based authentication, which stores user claims in the cookie itself. If we’re storing too many or large claims (like serialized user data, permissions, or tokens), the cookie can grow beyond the limit accepted by the server — especially on Linux-based Azure App Service which uses Nginx.

    solution:-- We should review and limit the number and size of claims added during sign-in. Only essential claims (like user ID or username) should be included.

    1. Cookie-Based TempData or ViewData- By default, ASP.NET Core stores TempData in cookies. If we’re storing large messages, error details, or return URLs in TempData, it will inflate the cookie size.

    solution:-- We can switch TempData to use session-based storage by updating our Startup.cs:

    services.AddSession();
    services.AddControllersWithViews()
            .AddSessionStateTempDataProvider();
    

    And in the middleware pipeline:

    app.UseSession();
    

    This keeps large data off the client and avoids oversized request headers.

    1. Another potential cause is if our login redirects (like ReturnUrl=...) include very long or encoded data — for example, if we’re appending serialized JSON or long query strings to the login URL.

    solution:-- We should avoid placing large data in the query string. Instead, store it in session or cache, and just pass a short key or ID in the URL.

    collective Keypoints-

    • Reviewing the size of cookies during login (check browser DevTools → Network).
    • Refactoring the ClaimsPrincipal to remove any unnecessary claims.
    • Switching TempData to session-backed storage.
    • Validating that redirect URLs are short and safe.

    Please refer ,

    https://learn.microsoft.com/en-us/aspnet/core/security/authentication/social/additional-claims?view=aspnetcore-9.0

    https://learn.microsoft.com/en-us/aspnet/core/fundamentals/app-state?view=aspnetcore-9.0

    https://learn.microsoft.com/en-us/entra/identity-platform/reply-url

    If you have any further assistant, do let me know.

    If the answer is helpful, please click Accept Answer and kindly upvote it so that other people who faces similar issue may get benefitted from it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.