///
/// 获取参数帮助类
///
public class ParamsHelper
{
///
/// 获取参数值
///
///
///
public static string GetParams(HttpContext context ) {
try
{
NameValueCollection form = HttpUtility.ParseQueryString(context.Request.QueryString.ToString());
HttpRequest request = context.Request;
string data = string.Empty;
switch (request.Method)
{
case "POST":
request.Body.Seek(0, SeekOrigin.Begin);
using (var reader = new StreamReader(request.Body, Encoding.UTF8))
{
data = reader.ReadToEnd();//3.0中默认禁用了AllowSynchronousIO 同步读取body的方式需要ConfigureServices中配置允许同步读取IO流否则可能会抛出异常,解决方法看文章最后
data = reader.ReadToEndAsync().Result;
}
break;
case "GET":
//第一步