Let’s understand the concept of the Blazor web assembly using a simple example.
First of all, go open visual studio 2019 and create a new project. Click on Ok. project selection screen
Fig: Project selection screen
After that select .NET core framework and select Blazor serverapp, click on create button after that you will see the screen exactly like below.
After finishing the create project process all Blazorappdefault structure look like that,WWWroot , Data,Pages,Shared,App.razor, that all file are created by default.
Fig: Project structure screen
Data folder is created by blazor, you can add all our Model and DBContext Class, Service, in blazor Webassembly.
When we create Blazor project at that time page folder create by the system in Pages folder you can add all our component files. All component file has the. razor extension with itsfile name.
_imports. razor file was generated at project creation time. using _Imports.razor file you can add all components of pages.
App.razor folder was also created by the system In the App.razor file we can add our main component using App.razoor file. blazor provide default component also. .Appsertings.json can be used for adding the database connection string.All Asp .NET application have .Appsettings .json file
Startup.cs file is the most important file where you add all our endpoints example like controller endpoints, HTTP Client, add services and DB context to be used in the startup configuration method.
When you run the Blazor application, you can see left side of navigation and the right side contains and data. Youcan see as the default sample pages and menus you can displayed on our Blazor web site. You can add pages or remove them and start with our own Blazor page.Now run the application and you will see the below screen.
Fig: output screen
The big advantage of Blazor is as you can use our C# code in the razor and also put the breakpoint in the c# code part and in the browser, you can debug and check for all our logic is working properly and to trace any kind of error easily with the breakpoint.