Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
A set of APIs across the Blazor Components assemblies that were previously marked obsolete have been removed in ASP.NET Core 11. Most of these APIs were marked obsolete several releases ago and have working replacements that have been recommended for years.
Version introduced
.NET 11
Previous behavior
Previously, the affected APIs compiled with an obsolete warning. Most of the warnings pointed at a replacement API. For example, calling EditContext.AddDataAnnotationsValidation() produced an obsolete warning recommending EnableDataAnnotationsValidation.
New behavior
In ASP.NET Core 11, the following APIs are removed and no longer compile.
Microsoft.AspNetCore.Components
Router.PreferExactMatchesproperty. The property has had no effect since exact-match routing became the default in .NET 6.ResourceAsset(string url)constructor overload.
Microsoft.AspNetCore.Components.Forms
EditContextDataAnnotationsExtensions.AddDataAnnotationsValidation(EditContext)extension method.EditContextDataAnnotationsExtensions.EnableDataAnnotationsValidation(EditContext)overload (the overload without anIServiceProviderparameter).RemoteBrowserFileStreamOptionsclass.
Microsoft.AspNetCore.Components.Web
WebEventCallbackFactoryEventArgsExtensionsclass and all of its extension methods.- The
initaccessor onWebRenderer.RendererId. The property is now set only via constructor.
Microsoft.AspNetCore.Components.WebAssembly
JSInteropMethods.NotifyLocationChanged(string, bool)method.
Microsoft.AspNetCore.Components.WebAssembly.Authentication
SignOutSessionStateManagerclass. The class has been a no-op since .NET 7.RemoteAuthenticationServiceconstructor overload that doesn't take a logger.AccessTokenResultconstructor and theRedirectUrlproperty.AccessTokenNotAvailableExceptionnow usesInteractiveRequestUrlin place of the removedRedirectUrl.
Type of breaking change
This change can affect source compatibility.
Reason for change
These APIs were marked obsolete in earlier releases (most between .NET 5 and .NET 8). Each had a documented replacement, and continuing to ship the obsolete surface area increased maintenance cost and surface area for Blazor without benefit. For more information, see dotnet/aspnetcore#62755.
Recommended action
Update your code to use the replacement APIs as listed in the following table.
| Removed API | Replacement |
|---|---|
Router.PreferExactMatches |
Remove the assignment. Exact matching has been the default since .NET 6. |
ResourceAsset(string url) |
ResourceAsset(string url, IReadOnlyList<ResourceAssetProperty>? properties) |
EditContextDataAnnotationsExtensions.AddDataAnnotationsValidation(EditContext) |
EditContextDataAnnotationsExtensions.EnableDataAnnotationsValidation(EditContext, IServiceProvider) |
EditContextDataAnnotationsExtensions.EnableDataAnnotationsValidation(EditContext) |
EditContextDataAnnotationsExtensions.EnableDataAnnotationsValidation(EditContext, IServiceProvider) |
RemoteBrowserFileStreamOptions |
BrowserFileStreamOptions |
WebEventCallbackFactoryEventArgsExtensions |
Use EventCallbackFactory directly. |
WebRenderer.RendererId.init accessor |
Pass RendererId via the WebRenderer constructor. |
JSInteropMethods.NotifyLocationChanged(string, bool) |
JSInteropMethods.NotifyLocationChanged(string uri, string? state, bool isInterceptedLink) (added in .NET 7). This method is for framework use only. |
SignOutSessionStateManager |
Delete usages. The class has been a no-op since .NET 7. |
RemoteAuthenticationService (constructor without logger) |
The remaining constructor takes an ILogger<RemoteAuthenticationService<...>> parameter. |
AccessTokenResult constructor and RedirectUrl property |
Use the remaining constructor and InteractiveRequestUrl. |
Affected APIs
- Microsoft.AspNetCore.Components.Routing.Router.PreferExactMatches
- Microsoft.AspNetCore.Components.Forms.EditContextDataAnnotationsExtensions.AddDataAnnotationsValidation
- Microsoft.AspNetCore.Components.Forms.EditContextDataAnnotationsExtensions.EnableDataAnnotationsValidation
Microsoft.AspNetCore.Components.Forms.RemoteBrowserFileStreamOptionsMicrosoft.AspNetCore.Components.Web.WebEventCallbackFactoryEventArgsExtensionsMicrosoft.AspNetCore.Components.RenderTree.WebRenderer.RendererId(init accessor)Microsoft.AspNetCore.Components.WebAssembly.Infrastructure.JSInteropMethods.NotifyLocationChanged(System.String, System.Boolean)Microsoft.AspNetCore.Components.WebAssembly.Authentication.SignOutSessionStateManagerMicrosoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService<TRemoteAuthenticationState, TAccount, TProviderOptions>(constructor overload without logger)Microsoft.AspNetCore.Components.WebAssembly.Authentication.AccessTokenResult(legacy constructor andRedirectUrlproperty)Microsoft.AspNetCore.Components.ResourceAsset(constructor overload withoutproperties)
ASP.NET Core