An ASP.NET and htmx meta-framework
The name RazorX represents the combination of ASP.NET Razor Components on the server with htmx on the client. ASP.NET Minimal APIs provide the request-response processing between the client and server. Razor Components are only used for server-side templating, and there are no dependencies on Blazor for routing or interactivity.
Install the required dependencies, if necessary.
- .NET SDK >= 9.0
- Node.js or similar JS runtime for tailwindcss
- Azurite VS Code extension
Download and install the template
- Download the
Package/RazorX.Template.1.0.0-alpha.nupkg
- Install the template
dotnet new install RazorX.Template.1.0.0-alpha.nupkg
- Create a new app with
dotnet new razorx
[OR]
Build and install the template
- Clone the razorx repository.
- Use the /RxTemplatePack/makefile to build and install the template. If you're on Windows, you may need to create the template manually by copying the RxTemplate folder to RxTemplatePack/content and running the dotnet CLI commands in the makefile.
- Create a new app with
dotnet new razorx
.
The following diagram describes the flow of a request. The basic concept is to first route the request through a series of middleware, both global and endpoint specific (IEndpointFilters
). This applies common behaviors like anti-forgery token validation, authorization policy enforcement, and model validation. Next, the request is routed to a specific handler (IRequestHandler Delegate
) for processing application logic. The request handler will usually return a RazorComponentResult
for creating an HTML response. Finally, HTMX may modify the DOM to swap partial content and trigger events specified in response headers. The events are handled with JavaScript event handlers in razorx.js
.