Files
2026-10-28 14:24:41 +02:00

20 lines
576 B
C#

using Microsoft.AspNetCore.Mvc.RazorPages;
using StatiKosev.Services;
namespace StatiKosev.Pages;
public class IndexModel(NtfyNotifier ntfy) : PageModel
{
public string VisitorName { get; private set; } = "";
public void OnGet()
{
VisitorName = User.Identity?.IsAuthenticated == true ? User.Identity.Name! : "";
var userAgent = Request.Headers.UserAgent.ToString();
ntfy.Notify("Home page visit",
$"{(VisitorName == "" ? "Guest" : VisitorName)}\n{userAgent[..Math.Min(userAgent.Length, 160)]}",
"eyes");
}
}