AspNetCore.Docs.Samples/security/authorization/AuthRequirementsData/Controllers/GreetingsController.cs

14 lines
354 B
C#
Raw Normal View History

2023-05-27 11:05:48 +08:00
using AuthRequirementsData.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace AuthRequirementsData.Controllers;
[ApiController]
[Route("api/[controller]")]
public class GreetingsController : Controller
{
[MinimumAgeAuthorize(16)]
[HttpGet("hello")]
2023-05-31 07:27:13 +08:00
public string Hello() => $"Hello {(HttpContext.User.Identity?.Name ?? "world")}!";
2023-05-27 11:05:48 +08:00
}