mirror of
https://github.com/AlexMacocian/Net.Sdk.Web.Extensions.git
synced 2026-07-22 16:59:30 +00:00
20 lines
521 B
C#
20 lines
521 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace AspNetCore.Extensions;
|
|
|
|
public class ForbiddenResponseActionResult : IActionResult
|
|
{
|
|
private readonly string reason;
|
|
|
|
public ForbiddenResponseActionResult(string reason)
|
|
{
|
|
this.reason = reason;
|
|
}
|
|
|
|
public Task ExecuteResultAsync(ActionContext context)
|
|
{
|
|
context.HttpContext.Response.StatusCode = StatusCodes.Status403Forbidden;
|
|
return context.HttpContext.Response.WriteAsync(reason, context.HttpContext.RequestAborted);
|
|
}
|
|
}
|