Files

20 lines
576 B
C#
Raw Permalink Normal View History

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