@page "/"
@page "/{Id:nonfile}"
@using Microsoft.Extensions.Caching.Distributed
@inject IDistributedCache Db
@inject NavigationManager Navigation
Startpage - Just Short It
@if (Id is null) {
Welcome to Just Short It!
The KISS single-user URL shortener!
Start shorting URLs
} else {
@ErrorMessage
}
@code {
[Parameter]
public string? Id { get; set; }
private string? ErrorMessage { get; set; }
protected override async Task OnInitializedAsync() {
if (Id is not null) {
string? data = await Db.GetStringAsync(Id);
if (data is not null) {
Navigation.NavigateTo(data, true);
} else {
ErrorMessage = "Redirect ID not found, it may have been deleted or expired";
}
}
}
}