Share via


Blazor:ProtectedBrowserStorage 功能已移至共用架構

在 ASP.NET Core 5.0 RC2 版本中,ProtectedBrowserStorage 功能已移至 ASP.NET Core 共用架構。

導入的版本

5.0 RC2

舊的行為

在 ASP.NET Core 5.0 Preview 8 中,此功能屬於 Microsoft.AspNetCore.Components.Web.Extensions 套件的一部分,但只能在 Blazor WebAssembly 中使用。

在 ASP.NET Core 5.0 RC1 中,此功能屬於 Microsoft.AspNetCore.Components.ProtectedBrowserStorage 套件的一部分,該套件參考 Microsoft.AspNetCore.App 共用架構。

新的行為

在 ASP.NET Core 5.0 RC2 中,參考及使用此功能時不再需要 NuGet 套件參考。

變更原因

移至共用架構能提升客戶所期待的使用者體驗。

若從 ASP.NET Core 5.0 RC1 升級,請完成下列步驟:

  1. 移除該專案的 Microsoft.AspNetCore.Components.ProtectedBrowserStorage 套件參考。
  2. using Microsoft.AspNetCore.Components.ProtectedBrowserStorage; 替換為 using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
  3. 從您的 AddProtectedBrowserStorage 類別移除 Startup 的呼叫。

若從 ASP.NET Core 5.0 Preview 8 升級,請完成下列步驟:

  1. 移除該專案的 Microsoft.AspNetCore.Components.Web.Extensions 套件參考。
  2. using Microsoft.AspNetCore.Components.Web.Extensions; 替換為 using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
  3. 從您的 AddProtectedBrowserStorage 類別移除 Startup 的呼叫。

受影響的 API