.net core api migrated after 3.0 Post 405 Method Not Allowed

The origin of the problem: the .NET Core API before using .net core 2.0 is developed, tested are normal, recently upgraded to 3.0, found api get normal, post tips 400,405 Method Not Allowed

Find a reason not found, the debug locally, an error message:

System.InvalidOperationException: Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.

Error reason: the .NET 3.0 Core does not allow synchronized operation, must be changed to asynchronous mode

Solution: the original ReadToEnd (), modified to ReadToEndAsync (), the problem is resolved.

            the using (the StreamReader Reader = new new the StreamReader (request.body, Encoding.UTF8)) 
            { 
                Result = the await reader.ReadToEndAsync (); // 3.0 upgrade allowed synchronous operation, asynchronous must 
                logger.info ( " FactoryBarCode: " + Result); 
            }

 

 

 

Guess you like

Origin www.cnblogs.com/jopny/p/11823010.html