-
Notifications
You must be signed in to change notification settings - Fork 0
Todo Sample
The Imp Todo sample is a small but complete ASP.NET Core application. It manages an in-memory list of tasks and demonstrates how Imp features fit together without introducing a database, authentication system, or frontend framework.
git clone https://github.com/KitchenPC/Imp.git
cd Imp
dotnet run --project Samples/TodoApp/TodoApp.csprojOpen the HTTP URL printed by ASP.NET Core. Tasks reset when the process restarts.
- Add a task.
- Complete or reopen it.
- Delete tasks and clear completed tasks.
- Filter all, active, or completed items through
?Filter=.... - View a task through
/todo/{id}. - Visit
/aboutfor a direct-rendered page. - Receive a real 404 status for unknown routes.
| File | What it demonstrates |
|---|---|
Program.cs |
Middleware order, DI registration, namespaces, fallback routing, CDN paths, lifecycle header. |
Pages/Default.cs |
Constructor injection, enum query binding, loops, dynamic output, async postback, antiforgery, validation. |
Pages/Todo.cs |
Dynamic permalink parsing and 404 for a missing record. |
Pages/About.cs |
Direct rendering without an embedded page template. |
Pages/NotFound.cs |
Configured 404 page and status. |
PageTemplates/*.htm |
Embedded page templates and dynamic commands. |
Templates/Site.htm |
Reusable layout and placeholders. |
wwwroot/styles/site.css |
Static assets referenced through Cdn.href. |
TodoStore |
Thread-safe singleton application service. |
The sample isolates Imp concepts. TodoStore is a singleton protected by a lock, so it demonstrates shared service lifetime and concurrent safety while remaining easy to run. Replace it with a repository/database service for durable or multi-instance deployment.
All state-changing forms use ASP.NET Core antiforgery tokens, validate an action allow-list, parse IDs, and HTML-encode task titles. The sample does not include [SecurePage] because a responsible example would require choosing and explaining a real authentication scheme. See Authentication and secure pages.
Samples/TodoApp.Tests verifies adding, normalization, toggling, removal, and input limits. The repository build also compiles all embedded resources. For a production application, add HTTP integration tests covering authentication, antiforgery, response status, and rendered output.
Imp is MIT licensed. See the source and Todo sample on GitHub.
Imp
Templates
Application integration
- Forms and antiforgery
- Dependency injection
- Authentication and secure pages
- Static assets and CDN paths
- Configuration reference
Help and reference