-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration Reference
Mike Christensen edited this page Aug 28, 2026
·
1 revision
UseImp accepts an action that builds one ImpConfiguration fluently:
app.UseImp(config => config
.PageAssembly(typeof(Program).Assembly)
.RootPageNamespace("MySite.Pages")
.RootTemplateNamespace("MySite.Templates")
.NotFoundPageType<MySite.Pages.NotFound>()
.OnNotFound(/* callback */)
.CdnPrefix("https://cdn.example.com")
.OnBuildCdnPath(/* callback */)
.OnPreRender(/* callback */)
.Authenticate(/* callback */));| Option | Purpose |
|---|---|
PageAssembly(Assembly) |
Assembly containing page types and embedded resources. Essential for most applications. |
RootPageNamespace(string) |
Namespace prefix joined to the request-derived type name. |
RootTemplateNamespace(string) |
Manifest-resource prefix for reusable templates referenced as Template.Name. |
NotFoundPageType<T>() |
Application page used when normal and fallback routing fail. |
OnNotFound(callback) |
Synchronous fallback route returning a page Type or null. |
CdnPrefix(string) |
Literal prefix applied to values of Cdn.* template attributes. |
OnBuildCdnPath(callback) |
Final rewrite of a CDN-aware path during compilation. |
OnPreRender(callback) |
Global synchronous hook before the page's PreRender. |
Authenticate(callback) |
Gate for pages carrying [SecurePage]; false stops rendering. |
app.UseImp(config => config
.PageAssembly(typeof(Program).Assembly)
.RootPageNamespace("MySite.Pages")
.RootTemplateNamespace("MySite.Templates")
.NotFoundPageType<MySite.Pages.NotFound>()
.OnNotFound(request =>
request.Path.StartsWithSegments("/article")
? typeof(MySite.Pages.Article)
: null)
.CdnPrefix(string.Empty)
.OnBuildCdnPath(path => path + "?v=1")
.OnPreRender((request, response) =>
response.Headers["X-Rendered-By"] = "Imp")
.Authenticate((context, page) =>
{
if (context.User.Identity?.IsAuthenticated == true)
return true;
context.Response.Redirect("/login");
return false;
}));All options are optional at the type level, but missing assembly/namespace/template configuration can prevent routing or resource resolution. No callback means that feature is skipped. In particular, a secure-page attribute has no effect without Authenticate.
Configuration is established when middleware is created. Treat it as immutable startup configuration rather than per-request state.
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