net core 接受post值

 public static string GetPostParams(HttpContext context)
        {
            string param = string.Empty;
            if (context.Request.Method.ToLower().Equals("post"))
            {
                param += "[post]";
                foreach (var key in context.Request.Form.Keys.ToList())
                {
                    param += key + ":" + context.Request.Form[key].ToString();
                }
            }
            else if (context.Request.Method.ToLower().Equals("get"))
            {
                param += "[get]"+context.Request.QueryString.Value;
            }
            else
            {
                param += "[" + context.Request.Method + "]";
            }

            return param;
        }
namespace Microsoft.AspNetCore.Mvc
public abstract class ControllerBase
{
    public HttpRequest Request { get; }
}
public abstract class HttpContext
{
    public abstract HttpRequest Request { get; }
}
    [HttpPost]
        public IActionResult P_Leave()
    {
        var title = Request.HttpContext;
            var t = Request.Form["sets"].ToString();
}

 

posted @ 2019-09-04 12:00  enych  阅读(3014)  评论(0编辑  收藏  举报