URL shortener and redirection
Package | NuGet |
---|---|
Shortr | |
Shortr.AspNetCore | |
Shortr.Npgsql |
This project can create short URLs (i.e: https://nugt.net/s/FqJFMC2) and redirect requests to the original URL.
You can see it in use in the NuGetTrends source code.
It offers an in-memory store, for testing. And a Postgres extension package and an ASP.NET Core extension to plug it into the request pipeline.
It also includes a web app to demonstrate its use from a JavaScript client.
By default it only generates links to URLs sharing the same BaseAddress
as configured for the application itself.
It's possible to change this behavior in different ways.
For example, allowing a direct URL to be created to any destination:
var options = new ShortrOptions
{
AllowRedirectToAnyDomain = true
}
The other options can be found here.
Make sure you have .NET Core 3, docker
and docker-compose
to run PostgreSQL
:
1. Start postgres with `docker-compose up`
2. Navigate to `src\Shortr.Web` and run `dotnet run`
3. Browser `http://localhost:5000`