├── BlazorCrud ├── Pages │ ├── Layouts │ │ ├── EmptyLayout.razor │ │ └── MainLayout.razor │ ├── Components │ │ ├── NavMenu.razor │ │ ├── RandomNumber.razor │ │ └── FlashMessages.razor │ ├── Routes.razor │ ├── _Imports.razor │ ├── App.razor │ ├── Contacts │ │ ├── List.razor │ │ ├── Create.razor │ │ ├── ContactsTable.razor │ │ └── Edit.razor │ └── Home │ │ └── Index.razor ├── wwwroot │ ├── favicon.png │ └── app.css ├── appsettings.Development.json ├── appsettings.json ├── BlazorCrud.csproj ├── Lib │ └── Extensions │ │ └── SessionExtensions.cs ├── Data │ └── Database.cs ├── Program.cs └── Properties │ └── launchSettings.json ├── BlazorCrud.sln ├── .gitattributes └── .gitignore /BlazorCrud/Pages/Layouts/EmptyLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | @Body -------------------------------------------------------------------------------- /BlazorCrud/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/westonwalker/BlazorSsrCrud/HEAD/BlazorCrud/wwwroot/favicon.png -------------------------------------------------------------------------------- /BlazorCrud/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /BlazorCrud/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /BlazorCrud/Pages/Components/NavMenu.razor: -------------------------------------------------------------------------------- 1 |
John Doe
5 |This is a demo on how to use Minimal APIs + Razor Components + HTMX to create dynamic server side rendered apps.
10 | Explore the crud example 11 |12 | You can check out the repo here 13 |
14 |15 | Using Minimal APIs and Razor components is possible because of a new class in .NET 8: RazorComponentResult 16 |
17 |This returns an IResult after initializing a Razor component, making it possible to use Razor components in Minimal APIs.
18 |22 | Requires .NET 8 RC1 installed. 23 |
24 |28 | The HTMX attribute hx-boost turns internal links into ajax calls. This speeds up site speed since there are no full page reloads. You can opt in and out of this behavior on a link by link basis. 29 |
30 |31 | This app uses hx-boost on the body tag, turning on this functionality for all links. 32 |
33 |37 | The HTMX attributes hx-get and hx-post sets up ajax calls to endpoints and swaps html on the page with what was returned. 38 |
39 |40 | This is useful for submitting forms, searching tables, and modifying the dom from a user interaction on the page. 41 |
42 |46 | The HTMX attribute hx-trigger can be used to poll the server. This can setup ajax calls to endpoints at an interval and swap html on the page with what was returned. 47 |
48 |49 | Below is random number generator. 50 |
51 |53 | HTMX calls /random-number every 2s and replaces the html with the html returned by the endpoint. 54 |
55 || Name | 28 |City | 30 |Phone | 31 ||
|---|---|---|---|
| No contacts with that name found. | 36 ||||
| 42 | 43 | @contact.Name 44 | 45 | | 46 |47 | 48 | @contact.Email 49 | 50 | | 51 |52 | 53 | @contact.City 54 | 55 | | 56 |57 | 58 | @contact.Phone 59 | 60 | | 61 |