From 8a4b839cd396029d14aff33a625d0d7a8f4e1f99 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 22 Oct 2019 12:56:28 -0700 Subject: [PATCH] Fixes in DownloadPersonalData (#14203) * Fixes in DownloadPersonalData * use SerializeToUTf8 instead * Remove reference to newtonsoft --- src/Identity/UI/ref/Microsoft.AspNetCore.Identity.UI.csproj | 1 - .../Pages/V3/Account/Manage/DownloadPersonalData.cshtml.cs | 4 ++-- .../Pages/V4/Account/Manage/DownloadPersonalData.cshtml.cs | 4 ++-- src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj | 1 - 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Identity/UI/ref/Microsoft.AspNetCore.Identity.UI.csproj b/src/Identity/UI/ref/Microsoft.AspNetCore.Identity.UI.csproj index 51b7eca6c4..813c7c4dff 100644 --- a/src/Identity/UI/ref/Microsoft.AspNetCore.Identity.UI.csproj +++ b/src/Identity/UI/ref/Microsoft.AspNetCore.Identity.UI.csproj @@ -5,7 +5,6 @@ - diff --git a/src/Identity/UI/src/Areas/Identity/Pages/V3/Account/Manage/DownloadPersonalData.cshtml.cs b/src/Identity/UI/src/Areas/Identity/Pages/V3/Account/Manage/DownloadPersonalData.cshtml.cs index 5152d01e35..d0fdadaf93 100644 --- a/src/Identity/UI/src/Areas/Identity/Pages/V3/Account/Manage/DownloadPersonalData.cshtml.cs +++ b/src/Identity/UI/src/Areas/Identity/Pages/V3/Account/Manage/DownloadPersonalData.cshtml.cs @@ -5,11 +5,11 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.Json; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; -using Newtonsoft.Json; namespace Microsoft.AspNetCore.Identity.UI.V3.Pages.Account.Manage.Internal { @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Identity.UI.V3.Pages.Account.Manage.Internal personalData.Add($"Authenticator Key", await _userManager.GetAuthenticatorKeyAsync(user)); Response.Headers.Add("Content-Disposition", "attachment; filename=PersonalData.json"); - return new FileContentResult(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(personalData)), "text/json"); + return new FileContentResult(JsonSerializer.SerializeToUtf8Bytes(personalData), "application/json"); } } } diff --git a/src/Identity/UI/src/Areas/Identity/Pages/V4/Account/Manage/DownloadPersonalData.cshtml.cs b/src/Identity/UI/src/Areas/Identity/Pages/V4/Account/Manage/DownloadPersonalData.cshtml.cs index 8529e3b171..38d077f014 100644 --- a/src/Identity/UI/src/Areas/Identity/Pages/V4/Account/Manage/DownloadPersonalData.cshtml.cs +++ b/src/Identity/UI/src/Areas/Identity/Pages/V4/Account/Manage/DownloadPersonalData.cshtml.cs @@ -5,11 +5,11 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.Json; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; -using Newtonsoft.Json; namespace Microsoft.AspNetCore.Identity.UI.V4.Pages.Account.Manage.Internal { @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Identity.UI.V4.Pages.Account.Manage.Internal personalData.Add($"Authenticator Key", await _userManager.GetAuthenticatorKeyAsync(user)); Response.Headers.Add("Content-Disposition", "attachment; filename=PersonalData.json"); - return new FileContentResult(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(personalData)), "text/json"); + return new FileContentResult(JsonSerializer.SerializeToUtf8Bytes(personalData), "application/json"); } } } diff --git a/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj b/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj index d803f42f5a..f5a122a355 100644 --- a/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj +++ b/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj @@ -36,7 +36,6 @@ -