我是靠谱客的博主 美满嚓茶,最近开发中收集的这篇文章主要介绍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

最后

以上就是美满嚓茶为你收集整理的asp.net环境下web api接口接收参数方法的全部内容,希望文章能够帮你解决asp.net环境下web api接口接收参数方法所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(66)

评论列表共有 0 条评论

立即
投稿
返回
顶部