zhangtingzu

asp.net环境下web api接口接收参数方法

public static string GetRequestString(string name, string defaultValue)
{
            string result = defaultValue;
            if (HttpContext.Current != null && HttpContext.Current.Request != null)
            {
                if (HttpContext.Current.Request.QueryString[name] != null || HttpContext.Current.Request.Form[name] != null)
                {
                    result = HttpContext.Current.Request[name].ToString();
                }
            }
            return result;
}

string value = RequestUtil.GetRequestString("param", "");

缺点:当参数数据量比较大时,数据会被截断,需要用下面的方法。

[HttpPost]
public bool Write([FromBody] List<StudentEntity> model)
{
}

[HttpPost]
public bool Write<T>([FromBody]T model)
{
}

 

这样就可以接收大量数据了。

查看原文:

http://www.cnblogs.com/zhangtingzu/p/7060518.html

分类:

技术点:

相关文章:

  • 2021-09-16
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2023-03-09
  • 2022-12-23
  • 2021-12-10
  • 2022-01-15
相关资源
相似解决方案