|
| 1 | +# Migration Strategies |
| 2 | + |
| 3 | +Migration from ASP<span></span>.NET Web Forms to Blazor is not simple and this repository attempts to make it easier for developers to reuse as much of their Web Forms application as possible. The two technologies are 'concept compatible', but run on different implementations of the .NET runtime (.NET Framework vs. .NET Core / .NET 5+) |
| 4 | + |
| 5 | +We, the maintainers of this project, believe that with a little ingenuity the markup from a Web Forms application can be copied over with minimal changes and function similarly to its original purpose. We believe that well formatted and maintained code in Web Forms should be easily migrated. Applications that are a significant mix of C# and markup will have a more difficult time going through this process. |
| 6 | + |
| 7 | +## Known Required Changes |
| 8 | + |
| 9 | +There are several changes that are going to need to be made to the markup in your ASPX and ASCX files in order to get them working. Some of these are obvious changes, and some are considerations necessary for the razor templating and Blazor rendering engine. |
| 10 | + |
| 11 | +### Visual Basic converted to C# |
| 12 | + |
| 13 | +Blazor uses razor templates which only support the C# language. All Visual Basic in the markup will need to be converted to C#. |
| 14 | + |
| 15 | +### Bee-sting notation <% %> needs to be converted to @() notation |
| 16 | + |
| 17 | +ASP<span></span>.NET famously wrapped all .NET code in <% %>. Starting with ASP<span></span>.NET MVC and razor templates, all C# code is wrapped in @() syntax. |
| 18 | + |
| 19 | +### _Imports files needed |
| 20 | + |
| 21 | +In order to match some of the syntax previously available in Web Forms markup, a series of `using static` statements are necessary to allow the appropriate shims to work with your markup. You can find our sample of the `_Imports.razor` file here: **INSERT LINK** |
| 22 | + |
| 23 | +### User Controls (ASCX files) need to be converted to components |
| 24 | + |
| 25 | +Components are the building blocks for Blazor, just as controls were in Web Forms. If you have user controls in your application, you will need to convert those to components. See the UserControl strategy below for more details. |
| 26 | + |
| 27 | +### MasterPages are no more |
| 28 | + |
| 29 | +The concept of a MasterPage does not exist in Blazor. Instead, your ASPX pages will be loaded inside of a host page. You can compose a razor component that hosts other *converted ASPX pages* but your pages cannot dictate their parent container. See the MasterPage strategy below for more details. |
| 30 | + |
| 31 | +### Page Directive Changes |
| 32 | + |
| 33 | +### No Namespaces, No Tag-Prefixes |
| 34 | + |
| 35 | +Namespaces and tag-prefixes are gone. You can do a Find and Replace on asp: and remove those from your markup. |
| 36 | + |
| 37 | +## Strategies |
| 38 | + |
| 39 | +- A simple initial site migration |
| 40 | +- Intertwined code |
| 41 | +- Model-Binding |
| 42 | +- .NET Standard to the rescue! |
| 43 | +- Other considerations |
| 44 | + - MasterPage |
| 45 | + - Rearchitecting Web Application Layout |
| 46 | + - UserControls |
| 47 | + - The simple conversion |
0 commit comments