Last Updated: 13 Jun 2023 07:19 by Janick
Created on: 13 Jun 2023 07:19
Category: UI for ASP.NET Core
Type: Feature Request
Use TextWriter Async methods for HTML Helpers

Consider the use of TextWriter async methods for the HTML Helpers, for example the WriteInitializationScript methods.  In certain scenarios the use of the synchronous methods causes an exception: System.InvalidOperationException: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.

This can be resolved by explicitly enabling synchronous operations

services.Configure<IISServerOptions>(options =>
        options.AllowSynchronousIO = true;

though synchronous operations have been disabled by default at framework level as of .NET 3.0.