Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
ASP.NET Core Tag Helpers: Built-in Tag Helpers and Writing Your Own
A tag helper is a C# class, bound at compile time, that processes an HTML tag in Razor on the server; a single asp-for produces id, name, label, input type and data-val attributes. We look at the real output of the built-in anchor, form, input, select, environment and cache tag helpers, the difference from HTML Helpers and the build break from a missing @ on an enum attribute, then write our own <status-badge> and a permission-aware <secure-link>.
Razor Syntax and Layouts: @ Expressions, HTML Encoding, _Layout, Sections, _ViewStart and _ViewImports
Razor HTML-encodes every value written with @ by default; that shuts out XSS but also turns non-ASCII letters such as Turkish ı into entities like ı, fixed with WebEncoderOptions. With real output we cover implicit vs explicit expressions, the danger of Html.Raw and of embedding '@Model' in JavaScript, Json.Serialize, sections, the _ViewStart/_ViewImports hierarchy and the lost-section error in nested layouts.