Remove GetHtmlEncoder usage
This commit is contained in:
parent
7624d97114
commit
28cc5a4517
|
|
@ -10,7 +10,7 @@ using System.Text.Encodings.Web;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.FileProviders;
|
using Microsoft.AspNet.FileProviders;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
using Microsoft.Extensions.WebEncoders;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.StaticFiles
|
namespace Microsoft.AspNet.StaticFiles
|
||||||
{
|
{
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNet.StaticFiles
|
||||||
{
|
{
|
||||||
private const string TextHtmlUtf8 = "text/html; charset=utf-8";
|
private const string TextHtmlUtf8 = "text/html; charset=utf-8";
|
||||||
|
|
||||||
private static HtmlEncoder _htmlEncoder;
|
private HtmlEncoder _htmlEncoder;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates an HTML view for a directory.
|
/// Generates an HTML view for a directory.
|
||||||
|
|
@ -39,7 +39,7 @@ namespace Microsoft.AspNet.StaticFiles
|
||||||
|
|
||||||
if (_htmlEncoder == null)
|
if (_htmlEncoder == null)
|
||||||
{
|
{
|
||||||
_htmlEncoder = context.RequestServices.GetHtmlEncoder();
|
_htmlEncoder = context.RequestServices.GetRequiredService<HtmlEncoder>();
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Response.ContentType = TextHtmlUtf8;
|
context.Response.ContentType = TextHtmlUtf8;
|
||||||
|
|
@ -160,7 +160,7 @@ namespace Microsoft.AspNet.StaticFiles
|
||||||
return context.Response.Body.WriteAsync(bytes, 0, bytes.Length);
|
return context.Response.Body.WriteAsync(bytes, 0, bytes.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string HtmlEncode(string body)
|
private string HtmlEncode(string body)
|
||||||
{
|
{
|
||||||
return _htmlEncoder.Encode(body);
|
return _htmlEncoder.Encode(body);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue