diff --git a/HttpClientStudy.WebApp/Controllers/AdvancedGetController.cs b/HttpClientStudy.WebApp/Controllers/AdvancedGetController.cs
index df5bb05..d18a85e 100644
--- a/HttpClientStudy.WebApp/Controllers/AdvancedGetController.cs
+++ b/HttpClientStudy.WebApp/Controllers/AdvancedGetController.cs
@@ -28,14 +28,19 @@ namespace HttpClientStudy.WebApp.Controllers
///
///
[HttpGet]
+ [HttpPost]
public async Task GetWithBodyAsync()
{
- using (var reader = new StreamReader(Request.Body, Encoding.UTF8, detectEncodingFromByteOrderMarks: false, bufferSize: 1024, leaveOpen: true))
+ if (Request.ContentLength>0)
{
- var body = await reader.ReadToEndAsync();
- // 现在你有了请求体,可以按照你的需求处理它
+ using (var reader = new StreamReader(Request.Body, Encoding.UTF8, detectEncodingFromByteOrderMarks: false, bufferSize: 1024, leaveOpen: true))
+ {
+ var body = await reader.ReadToEndAsync();
+ // 现在你有了请求体,可以按照你的需求处理它
+ }
}
+
var reslut = BaseResultUtil.Success("操作成功");
return Ok(reslut);
}
diff --git a/HttpClientStudy.WebApp/Program.cs b/HttpClientStudy.WebApp/Program.cs
index 536753f..45e4f78 100644
--- a/HttpClientStudy.WebApp/Program.cs
+++ b/HttpClientStudy.WebApp/Program.cs
@@ -40,8 +40,9 @@ namespace HttpClientStudy.WebApp
//Kestrelѡ
builder.Services.Configure( option =>
{
- //ͬ IO (getbody)
+ //(getbody)
//ASP.NET Core 3.0 ֮ǰİ汾AllowSynchronousIO Ĭǿ
+ // true ͬ IO ,Getе.ֱֻӴжȡԶģͰ
option.AllowSynchronousIO = true;
});