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(); }