Frontend
The frontend is the part of an application that users see and operate: pages, forms, controls. On the web it consists of HTML, CSS, and script; in .NET it can be written in C# with Blazor.
The frontend is the part of an application that users see and operate: pages, forms, buttons, lists. It takes input and shows the answers of the backend.
What a web frontend is made of
The browser understands three things: HTML gives the content structure and meaning (HTML), CSS styles it, and script makes it interactive. A good frontend is also fast, usable on every screen size, and accessible (following the WCAG, the Web Content Accessibility Guidelines). Designing how it is operated is the topic of the user interface and user experience.
A frontend with .NET: Blazor
Beside the usual JavaScript libraries, .NET has Blazor: components written in C# and Razor syntax instead of JavaScript. Microsoft names four render modes in a Blazor Web App:
- Static SSR: The server creates HTML, without interactivity.
- Interactive Server: The user interface stays on the server, and events travel over a real-time connection.
- Interactive WebAssembly: The user interface runs in the browser with a .NET runtime on WebAssembly.
- Interactive Auto: First on the server, later in the browser.
Static SSR is fast and does without a large script bundle; interactivity is added where it is needed. Where script is needed after all, we write it as TypeScript and build it in the build.
An example from the Kladde
The Kladde starts its user interface with static SSR: lists of contacts, forms without script, and the public appointment booking with free times. Only after that do interactive islands come in, where they bring a real benefit. The Kladde comes in two languages, and its user interface is built to be accessible.
Common misconceptions
- Frontend does not just mean "making it pretty". Accessibility, speed, and error states (an empty list, not found) are part of it.
- Frontend is not the same as JavaScript. Blazor or plain HTML with a form is frontend too.
- Checks in the frontend do not replace a check in the backend. Anyone can forge what the browser sends.
- Whoever builds frontend and backend works full stack; a web app covers both.
In the course
You learn the frontend in K2: module 2.1 with HTML with meaning and Accessibility with WCAG 2.2, module 2.5 with The Blazor Web App and The public appointment booking. Script in moderation is covered in module 2.2 in Script in moderation: TypeScript in the build.
Further reading on the blog
Sources
- Microsoft Learn, ASP.NET Core Blazor render modes: https://learn.microsoft.com/aspnet/core/blazor/components/render-modes?view=aspnetcore-10.0
- Microsoft Learn, ASP.NET Core Blazor: https://learn.microsoft.com/aspnet/core/blazor/?view=aspnetcore-10.0