[英]How to pass string[] type parameters from jquery to asp.net web api method?
[英]how to pass parameters to asp.net web api get method?
以下是我在ASP.NET Web API中的get方法。
[HttpGet]
public IHttpActionResult GetDetails([FromBody] RetrieveDetails eDetails)
{}
以下是课程
public class RetrieveDetails
{
public string name{ get; set; }
public string Type { get; set; }
}
当我尝试从Fiddler调用GetDetails
, eDetails
始终为null。
http:// localhost:101222 / api / emailservice / GetDetails?name = testname&Type = testtype
我尝试了其他方法,但该值始终为null。 如果我将[HttpGet]更改为[HttpPost]并添加请求主体,则其工作正常。 但是我需要获取方法。
如果要在GET的URL中传递值,是否需要[FromBody]。 如果要在查询字符串中传递值,则应使用[FromUri]。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.