This guide walks you through creating your first Wisp application from scratch.
We’ll build a minimal web app with a controller and a template-based view.
Create a new Console project
Wisp is designed to work with a plain console project:
dotnet new console -n MyWispApp
cd MyWispApp
Add the Wisp Framework package
Add the Wisp NuGet package to your project
dotnet add package Wisp.Framework
Configure and start Wisp
In Program.cs
, configure Wisp, add routes, and start the server:
using Wisp.Framework;
var appBuilder = new WispHostBuilder().Build();
appBuilder
.UseControllers(); // Enable controller discovery
.ConfigureRoutes(r =>
{
// Add a simple Hello World route
r.Get("/hello", async ctx => WispHttpResponse.Ok("Hello, World!");
});
var app = appBuilder.Build();
// Run the app
await app.RunAsync();
Create a controller
Any class annotated with the [Controller]
attribute will be discovered automatically.
Add a new class HomeController.cs
:
[Controller]
public class HomeController : ControllerBase
{
[Route("/")]
public async Task<IView> Index()
{
return View("demo");
}
}
And a template view
Create a Templates
directory in your project root and add demo.liquid
:
<h1>Hello, World!</h1>
Run your app
Start your project with dotnet run
Open your app in a browser
Go to http://localhost:6969 and have fun