.net core api迁移 3.0后Post 405 Method Not Allowed
问题由来:.net core api之前是用 .net core 2.0开发的,测试过都是正常的,近期升级到了3.0,发现api get正常,post提示400,405 Method Not Allowed
查找没有找到原因,就在本地调试,提示错误信息:
System.InvalidOperationException: Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.
错误原因:.net core 3.0不允许同步操作,必须改成异步方式
解决方法:将原来的ReadToEnd(),修改为ReadToEndAsync(), 问题得到解决。
using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
{
result = await reader.ReadToEndAsync(); //升级3.0不允许同步操作,必须异步
Logger.Info("FactoryBarCode:" + result);
}
另一种办法:
It's worth noting that if you host on kestrel directly then your Program.cs should have appropriate ConfigureKestrel call public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureKestrel((context, options) =>
{
options.AllowSynchronousIO = true;
})
.net core api迁移 3.0后Post 405 Method Not Allowed的更多相关文章
- yii2 RESTful API 405 Method Not Allowed
关于 Yii2 中 RESTful API 的开发,可以参考另一篇随笔 http://www.cnblogs.com/ganiks/p/yii2-restful-api-dev.html 测试的过程中 ...
- .Net Core API 发布到IIS后,如何配置SSL详细步骤
一.首先,我们要将API发布到IIS,不脱机工作.但是这里会有问题,调用接口时,会返回 也就是说,我们需要配置SSL.接下来我们就来详细说明. 二.域名商提供SSL证书审核. 我的域名提供商是腾讯,直 ...
- 部署Web API后Delete请求总是报 405(Method Not Allowed)解决办法
WebDAV 安装IIS的时候如果选择了WebDAV(Web Distribution Authorization Versioning) Publish,则所有的 ...
- webapi 跨域 (MVC-Web API: 405 method not allowed问题 )
使用webapi cors 1.安装包:Install-Package Microsoft.AspNet.WebApi.Cors –IncludePrerelease 2.在webapiconfig. ...
- ASP.NET Core API ---状态码
摘录自:https://www.cnblogs.com/cgzl/p/9047626.html 状态码是非常重要的,因为只有状态码会告诉API的消费者: 请求是否如预期的成功,或者失败 如果出现了错误 ...
- ABP PUT、DELETE请求错误405.0 - Method Not Allowed 因为使用了无效方法(HTTP 谓词) 引发客户端错误 No 'Access-Control-Allow-Origin' header is present on the requested resource
先请检查是否是跨域配置问题,请参考博客:http://www.cnblogs.com/donaldtdz/p/7882225.html 一.问题描述 ABP angular前端部署后,查询,新增都没问 ...
- Asp.Net Core IIS发布后PUT、DELETE请求错误405.0 - Method Not Allowed 因为使用了无效方法(HTTP 谓词)
一.在使用Asp.net WebAPI 或Asp.Net Core WebAPI 时 ,如果使用了Delete请求谓词,本地生产环境正常,线上发布环境报错. 服务器返回405,请求谓词无效. 二.问题 ...
- 手把手教你从Core Data迁移到Realm
来源:一缕殇流化隐半边冰霜 (@halfrost ) 链接:http://www.jianshu.com/p/d79b2b1bfa72 前言 看了这篇文章的标题,也许有些人还不知道Realm是什么,那 ...
- 手把手教你从 Core Data 迁移到 Realm
前言 看了这篇文章的标题,也许有些人还不知道Realm是什么,那么我先简单介绍一下这个新生的数据库.号称是用来替代SQLite 和 Core Data的.Realm有以下优点: 使用方便 Realm并 ...
随机推荐
- Internet History, Technology, and Security(week3)——History: The Web Makes it Easy to Use
前言: 上周学习了第一个网络NSFnet,美国国家科学基金会(National Science Foundation,简称NSF)在全美国建立了6个超级计算机中心所互联的一个网络,这周继续学习网络的发 ...
- Android 输入法截取key优先于view
为了验证编写了个例子 首先是输入法 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 public class RemoteKeyboard exte ...
- Wowza 4 vod 录播多层目录无法播放问题
找到一个解决方案,但是无法下载zip包 https://stackoverflow.com/questions/21303361/how-to-stream-mp4-files-from-subdir ...
- 线性回归 r python 比较
w http://blog.sina.cn/dpool/blog/s/blog_70f632090101bp8u.html
- log4j 不输出mybatis的sql
有可能导入多个日志工具jar,导致mybatis不知道使用哪种日志.修改你的mybatis配置,添加setting,指定日志类型为log4j. <configuration> <!- ...
- set()运算
1 计算两个list的关系时,可转化为set进行运算. 参考:https://www.runoob.com/python3/python3-set.html a =[1,4,3,5,6,6,7,7,7 ...
- 字符串中的TRIM操作
std::string& ltrim(std::string& str, const std::string& chars = "\t\n\v\f\r ") ...
- Learn Python the hard way, ex45 对象、类、以及从属关系
#!/usr/bin/python #coding:utf-8 # animal is-a object(yes,sort of sonfusing)look at the extra credit ...
- final关键字的案例
package com.company.java.oop.cls; class ClassF { // static ClassF instance =new ClassF(); static { S ...
- openstack 制作镜像以及windows向Linux中通过xshell传文件
慢慢的也要把openstack一些相关的笔记整理上来了 之前由于主要是在看horizon 实验室搭建的openstack平台并没有怎么实际的用起来,前几天别的同学要用来测试大数据的相关服务,才把这些内 ...