Blazor Flashcards
Is blazor client side scripting or server side scripting ?
Blazor supports both client side and server side scripting
How can browser execute c# code
Blazor can run c# code in web using webassembly
What are blazor hosting models
Blazor web assembly and Blazor Server
How blazor web assembly works
Application runs in browser on web assembly . Compiled application code , its dependencies and .net run time are downloaded to the browser
What is blazor server?
Application is executed on the server. Between client and server a signalR connection is established . When event occurs , it is sent to server through signalR connection . Only the difference div is passed to the browser not the entire div. In this way it is optimized
What are pros of blazor web assembly model
Active server connection is not required , client resources and capabilities are used , full blown asp.net core web server is not required , can be hosted on own server , cloud , azure or CDN
Cons of web asembly model
Very first request takes long time
What are pros of blazor server
App loads much faster
Runs on server resources
More secure since app code is not sent
What are cons of blazor
ASP.Net core Server is required
Active connection to server is required
Higher latency
Scalability can be a challenge
What is the entry point of blazor app
Main method inside program.cs
Is startup.cs specific to Blazor server app?
Yes , it is specific only to server app and has configure () , configureservices () methods
What does mapblazorhub() do?
It sets up signal R connection between browser and server
What are buliding blocks of blazor application
Components are building blocks of razor application
What is the root component ?
App.razor
What does blazor.server.js reference do in _Host.cshtml
It sets up realtime signalR connection between browser and server
How to specify which files to be loaded based on relative path in url
Using @page directive in the razor file
Eg:- @page “/“ , @page “/about”
How component rendering works ?
App.Razor handles the routing , if for a given route a component is present it renders using <found></found> property else uses <notfound></> property</notfound>
To what layout file are the components rendered?
Components are rendered to @Body directive specified in MainLayout.razor
What file is similar to view.cshtml?
_Imports.razor file is similar to view.cshtml it contains all the assembly references needed by razor components instead of specifying them individually in each file
What does appsettings.json contain?
Just like .net mvc core application , It contains configuration settings
What is the root file in blazor web assembly ?
Index.html is the root file. This file is responsible for downloading all the dependencies and starting run time
Can we modify the blazor web assembly to blazor server and vice versa ?
Yes , since blazor componets form the basis of the application . If properly written we can interchange both the versions
What is blazor ?
Blazor is a component driven framework . Components can be nested , reused and shared across multiple projects . Components have .razor extension . Component names must start with uppercase charcter
How to access variables from code to html
By prefixing @ for variable names defined in code we can access the variables in html
What is razor component ?
It is a combination of html and c# code