Skip to main content

Posts

Showing posts with the label ASP.NET

Sharing Auth Cookies Between Legacy ASP.NET WebForms and Next.js Using YARP

  The "Strangler Fig" pattern is the de facto standard for modernizing monoliths, but it introduces a distinct architectural fracture: identity. When you place a Next.js micro-frontend alongside a legacy ASP.NET 4.x application, they live in different runtimes. A browser cookie issued by ASP.NET WebForms (encrypted with MachineKey) is an opaque, undecipherable blob to a Node.js server. Consequently, users navigating from  /legacy/dashboard  to  /next/profile  effectively "log out" because the Next.js server cannot validate the session credentials. This post details how to bridge that gap using  YARP (Yet Another Reverse Proxy)  as an authentication gateway, ensuring seamless session propagation without rewriting your legacy authentication logic immediately. The Root Cause: Incompatible Encryption The failure isn't in the transport; the browser successfully sends the cookie to both paths (assuming correct domain scope). The failure is in  decryptio...

Strangler Fig Strategy: Sharing Auth Cookies Between Legacy ASP.NET and Next.js

  The Hook: The "Unauthenticated" Glitch You are migrating a monolithic ASP.NET application to Next.js using the Strangler Fig pattern. You have set up a reverse proxy (YARP, Nginx, or CloudFront) to route  /app  to Next.js and everything else to the legacy backend. The user logs in via the legacy ASP.NET login form. They are redirected to the homepage successfully. Then, they click a link pointing to the new Next.js dashboard. Result:  They are immediately redirected back to the login page. Despite the browser sending the  .AspNetCore.Cookies  (or  .ASPXAUTH ) cookie with every request, Next.js treats the user as a stranger. You effectively have two isolated silos sharing a domain but failing to share state. The Root Cause: Incompatible Cryptography The issue is not network routing; it is cryptographic serialization. Serialization:  When a user logs in, ASP.NET creates an  AuthenticationTicket . It serializes this .NET object into binary. En...