翟家慧,结婚当天遭挖苦,胡歌白冰公开恋情
在进行 asp.netcore.mvc 文件上传时,后台无法正常读取文件流保存,出现:synchronous operations are disallowed. call writeasync or set allowsynchronousio to true instead.
查找资料,发现需要添加允许条件,才可以; 感谢:
有三种解决方式:第一种:在处理文件的action 中添加:
var synciofeature = httpcontext.features.get<ihttpbodycontrolfeature>(); if (synciofeature != null) { synciofeature.allowsynchronousio = true; }
第二种:或者在startup.cs 中注册
public void configureservices(iservicecollection services) { // if using kestrel: services.configure<kestrelserveroptions>(options => { options.allowsynchronousio = true; }); // if using iis: services.configure<iisserveroptions>(options => { options.allowsynchronousio = true; });
}
第三种:(不太理解。。。)
request.enablebuffering(); using (var reader = new streamreader(request.body, encoding: encoding.utf8)) { var body = reader.readtoendasync(); // do some processing with body… // reset the request body stream position so the next middleware can read it request.body.position = 0; }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Blazor server side 自家的一些开源的, 实用型项目的进度之 CEF客户端
.NET IoC模式依赖反转(DIP)、控制反转(Ioc)、依赖注入(DI)
vue+.netcore可支持业务代码扩展的开发框架 VOL.Vue 2.0版本发布
网友评论