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

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

转载于:https://www.cnblogs.com/zhangtingzu/p/7060518.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值