21 lines
601 B
C#
21 lines
601 B
C#
using System.Net;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
|
|
|
namespace Umbraco.Extensions
|
|
{
|
|
public static class ActionResultExtensions
|
|
{
|
|
public static bool IsSuccessStatusCode(this ActionResult actionResult)
|
|
{
|
|
var statusCode = actionResult switch
|
|
{
|
|
IStatusCodeActionResult x => x.StatusCode,
|
|
_ => (int?)null
|
|
};
|
|
|
|
return statusCode.HasValue && statusCode.Value >= (int)HttpStatusCode.OK && statusCode.Value < (int) HttpStatusCode.Ambiguous;
|
|
}
|
|
}
|
|
}
|