Share via

Migrating from WebForms to Blazor

Kuler Master 411 Reputation points
2024-02-19T07:37:55.21+00:00

We are currently using ASP.NET WebForms for all sections including, Front pages, Administration and various control panels for different client types.

Obviously we want to migrate to ASP.NET Blazor but in the first phase we want to migrate only the front pages.

Meaning, we will have a new Project of Blazor type where the front pages will reside and old one of WebForms type where the administration and control panels will reside.

My question is, how we can mix these two technologies in a single domain www.xyz.com without having subdomains? Any suggestion is welcome.

Thank you!

Windows development | Internet Information Services
Developer technologies | .NET | Blazor
Developer technologies | ASP.NET Core | Other

Answer accepted by question author

Anonymous
2024-02-19T08:56:39.3466667+00:00

Hi @Kuler Master ,

My question is, how we can mix these two technologies in a single domain www.xyz.com without having subdomains? Any suggestion is welcome.

Using IIS Reverse proxy or Yarp, both of them could achieve your requirement. If you are using the Yarp, you could create a front-end asp.net core application, then put the yarp rule inside it. The rule contains two conditions, which will rewrite the url to different application as you wish, like front-end to blazor's application, other url to old WebForms. For example: 1.Create a new asp.net core application and Install Yarp.ReverseProxy package from Nuget 2.Add usage in the application

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddReverseProxy()
    .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
var app = builder.Build();
app.MapReverseProxy();
app.Run();

3.Modify the appsettings.json like below: If the url contain the admin, it will go to the webform url, if the url doesn't contain anything it will go to blazor.

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "ReverseProxy": {
    "Routes": {
      "route1": {
        "ClusterId": "cluster1",
        "Order": 100, // Lower numbers have higher precedence
        "Match": {
          "Path": "admin/{**catch-all}"
        }
      },
      "minimumroute": {
        // Matches anything and routes it to www.example.com
        "ClusterId": "minimumcluster",
        "Order": 200, // Lower numbers have higher precedence
        "Match": {
          "Path": "{**catch-all}"
        }
      }
    },
    "Clusters": {
      "cluster1": {
        "Destinations": {
          "destination1": {
            "Address": "https://webform.com/"
          }
        }
      },
      "minimumcluster": {
        "Destinations": {
          "example.com": {
            "Address": "http://www.blazor.com/"
          }
        }
      }
    }
  }
}

More details, about how yarp works, you could refer to this article(https://microsoft.github.io/reverse-proxy/articles/getting-started.html) and this MSFT document(https://learn.microsoft.com/en-us/aspnet/core/migration/inc/overview?view=aspnetcore-8.0).

---If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

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