asp.netarchitecturewebformsblazor

How to extend ASP.Net Web Forms app adding Blazor?


We have a large legacy web forms application. We would like to continue to extend the functionality of it (add new pages). But we would like to stop adding more Web Forms code and instead would like to use Blazor to develop all new features going forward.

Ideally, a link from a Web Form page would redirect the browser to a page served by a Blazor app and vice-versa and the transition would be indistinguishable to the user.

Is this possible? If yes, how can it be done?

Also, what about authentication? Ideally, the user would login in our existing Web Form app and would not need to login again when transitioning to the Blazor app.


Solution

  • What I did:

    Host the blazor application in a subfolder under the existing app:

    myapp.com/oldapp

    myapp.com/oldapp/blazor

    You can just add links between them, If you use the same layout users should not notice.

    Now because you are using the same hostname, you can issue a cookie with a JWT token on login in the old app, and because the new app runs on the same hostname the blazor app can pickup this cookie and use the token to do requests to a new backend API that is also using JWT auth.