2020-02-20 08:33:28 +01:00
|
|
|
using System;
|
2020-02-19 10:18:27 +01:00
|
|
|
using System.Web;
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web
|
|
|
|
|
{
|
|
|
|
|
public static class HttpContextAccessorExtensions
|
|
|
|
|
{
|
|
|
|
|
public static HttpContextBase GetRequiredHttpContext(this IHttpContextAccessor httpContextAccessor)
|
|
|
|
|
{
|
|
|
|
|
var httpContext = httpContextAccessor.HttpContext;
|
|
|
|
|
|
2020-02-20 08:33:28 +01:00
|
|
|
if(httpContext is null) throw new InvalidOperationException("HttpContext is null");
|
2020-02-19 10:18:27 +01:00
|
|
|
|
|
|
|
|
return httpContext;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|