Modernizing Web Forms to .NET 6 Blazor

by | Mar 31, 2022 | Blog, Dev Team

Microsoft announced that .NET Framework 4.8 is no longer under active development. Microsoft will still be including it in their Windows Operating System with monthly security and reliability fixes – but they recommend that new development should be done in .NET 6 or later.

What does this mean for all your old .NET Framework 4.x Web Form applications?

Bottom line, they will become increasingly outdated as new technologies evolve and at some point, you will need to modernize them to take advantage of .NET 6+.

That being said – what’s the best way to modernize a .NET Framework 4.x Web Forms application?

Given that you use .NET Framework 4.x, your developers are likely to be familiar with the Microsoft stack. The best advice is to play to your developer’s strengths and modernize towards the latest core Microsoft products.

The user experience closest to Web Forms is Blazor/WASM and this will make it a relatively easy transition for your developers. There are many advantages to adopting Blazor that we will cover in detail in future blogs on this topic. For now, you need to know that:

  • Blazor/WASM is built on an open standard that is supported on all browsers
  • Blazor has a large and active open-source community
  • Blazor components can be including in hybrid MAUI applications which means they can be reused in cross-platform native mobile and desktop applications
  • Blazor enables the use of C# for much of the user experience that was done in JavaScript
  • Blazor is super developer friendly and allows the creation of reactive, rich user experiences
  • Blazor is a high performance platform with excellent stability and scalability
  • Debugging Blazor is easy with Visual Studio both in the backend and in the browser
  • Blazor components can be refactored into Razor class libraries for reuse across all of your cross-platform projects
  • Microsoft has put a lot of development effort into the Blazor technology over the past 4+ years
  • Microsoft has put Blazor at the heart of their application user experience

For a typical Web Form application there are three levels at which we will need to modernize:

  • User Experience – The website the user interacts with and possible cross platform extension to desktop and mobile devices
  • Refactoring Business Logic – The automated workflow that support the tasks performed by business users
  • Data Model – The structure of the data being maintained by the application

User Experience

The bad news first: .NET Framework 4.x Web Forms user experience is a legacy platform that will need to be completely replaced when migrating to .NET 6+. This means that you will not be able to reuse your existing .aspx pages or underlying code-behind source.

If you have several big applications with hundreds of web forms and millions of lines of code, you may be thinking that sounds both expensive and risky. If you were planning to do a simple application rewrite, replacing each web form with its Blazor equivalent you would be right.

Great Ideaz has already been through this process, and we can offer you an alternative approach with trellispark that can significantly reduce your costs and risks.

For most web form applications, a good 95%+ of the user experience source code is performing basic Create, Read, Update and Delete (CRUD) functionality. It is making sure that the user is only seeing allowed data and only performing allowed actions.

trellispark changes the way you develop and eliminates all the CRUD code from your application and provides a robust framework for refactoring your business logic into a sustainable microservice architecture. This eliminates most of the modernization effort/risk and significantly reduces your time to market so you can deliver value faster.

Refactoring Business Logic

Many Web Forms applications include some level of business logic to automate workflow processes. Over time this business logic gets incorporated into the form’s code-behind either as:

  • A business logic class library that is called by the form’s code-behind
  • Actual form code-behind that manipulates the database directly using stored procedures
  • Dynamic SQL created by the form code-behind as the user interacts with the website that is then executed against the database

Modernizing web forms to use Blazor means that all the existing code-behind will need to be replaced. This means that the existing business logic will need to be refactored.

Refactoring the business logic should be seen as an opportunity to improve the efficiency and sustainability of your new Blazor application.

If you are using the recommended Blazor/WASM approach, then you need to be careful about what you send to the client’s browser. Essentially, anything that goes to the browser is exposed to the user, or the person trying to hack your application. To address this security consideration, a great option is to implement a Web API that will be called by your Blazor client.

Using a Web API between your Blazor/WASM and database has several important benefits:

  • It is more secure – you only need to pass data to the browser that will be displayed. All the information, connections and processing that drives your business logic can be placed inside the Web API. This makes your applications more secure and robust
  • It is faster – you are only sending a subset of the data to the browser, the Blazor application figures out how to format the display on the client’s browser. This reduces the network bandwidth and leverages the processing power of the client to render the user experience faster
  • It is more scalable – you maintain state data inside the client browser and provide completely stateless Web API endpoints that can be load balanced as required
  • It is cross-platform – you can reuse your Blazor components in MAUI native applications on mobile devices and desktops. This means that you can also reuse the same Web API across all platforms
  • It is more sustainable – your code is cleaner. Your business logic endpoint only executes the minimum code required to implement the workflow. This makes the code easier to design, build, test and deploy. Your modernization of the web form user experience also gives you the best path to a modern microservice architecture

Data Model

Many Web Form applications built over traditional relational databases have extensive backlogs of outstanding changes or fixes. They become an anchor to the past rather than a driver for business change.

A seemingly simple request to add a new field to support a change to a business rule can take months to be implemented. Removal of obsolete fields can also be problematic. Making changes to support new types of customers, products, orders, etc. can become major application enhancements requiring large projects with long timelines, big budgets, and significant business risks.

Reviewing and updating the data model when modernizing a Web Forms application should be viewed as an opportunity to clear the existing change/fix backlogs. This is a two-fold opportunity:

  • Firstly – tidy up the existing data model by adding/trimming fields as required and introducing new concepts
  • Secondly – move to a data agnostic service model so that these types of changes/fixes are much easier to make in the future

The key idea around a data agnostic service approach is to store all your record data using XML or JSON. This enables you to add/remove fields to your records at will, without having a major impact on your database design or application user experience. You can also easily add new types of records, or recombine existing record data in new ways, to support changes to your business model.

The trellispark framework provides capabilities that simplify migrating your existing relational database models into a data agnostic record storage.

Conclusion

Enterprises with Web Form applications will inevitably have to modernize their websites in the coming years.

For the many reasons, moving to Blazor/WASM is likely to be the preferred solution.

Modernizing Web Forms applications shouldn’t be an expensive and risky IT led project to replace obsolete technology providing little, if any, business benefit.

Modernization should be embraced as a positive opportunity to adopt a more sustainable enterprise architecture and deliver tangible business benefits now and into the future.

The pace of innovation with technology has been accelerating across every industry over the last several years. Relentless innovation is increasingly a key business driver for success.

Great Ideaz has already been through this process and has developed the trellispark framework to jumpstart your modernization efforts. You can download trellispark from our customer portal and access free useful training materials at trellispark Academy.

To get started you can: