Samples
Learning pages for Razor Pages and htmx. This area only exists in Development; in any other environment its routes are removed (see Program.cs).
How a Razor Page is put together
- The page (
Basics.cshtml): HTML plus Razor.@pagemakes it reachable at a URL, here/Samples/Basics, from its area and file name. - The page model (
Basics.cshtml.cs): a C# class with handler methods.OnGetruns for a GET,OnPostfor a form POST, andOnGetSearch/OnPostGreetare named handlers, selected with?handler=Search. - Partials (
_SearchResults.cshtml): reusable HTML fragments. Files starting with_have no URL of their own. - Tag helpers such as
asp-forandasp-pagegenerate the right names, ids, links and validation markup from your C# model. - Everything written with
@is HTML-encoded automatically, which protects against cross-site scripting.
Razor Pages basics
A classic form: model binding, validation, and Post/Redirect/Get. No JavaScript.
Map
The hotline map's spike: Azure Maps and its drawing tools under the map pages' policy, signed in with a token from our server. Needs Maps__Azure__ClientId and az login.
htmx samples
The same page model ideas, but parts of the page update themselves through htmx attributes: load on click, live search, a form posted without a page reload, and polling.