From 40dddb33164e23a5b132dd876884d8dd6d4818c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Thu, 29 Sep 2022 18:01:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=AF=B7=E6=B1=82=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=89=A9=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yi.Framework.WebCore/CommonExtend.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs index 8d269644..f6b28d9a 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs @@ -132,5 +132,24 @@ namespace Yi.Framework.WebCore return ""; } + + + public static string GetRequestValue(this HttpContext context, string reqMethod) + { + string param; + + if (HttpMethods.IsPost(reqMethod) || HttpMethods.IsPut(reqMethod)) + { + context.Request.Body.Seek(0, SeekOrigin.Begin); + using var reader = new StreamReader(context.Request.Body, Encoding.UTF8); + //需要使用异步方式才能获取 + param = reader.ReadToEndAsync().Result; + } + else + { + param = context.Request.QueryString.Value.ToString(); + } + return param; + } } }