Web Api Parameter always null

后端 未结 4 2096
忘了有多久
忘了有多久 2020-12-01 02:25

Why is the parameter always null when I call the below Post method with the below ajax?

public IEnumerable Post([FromBody]string value)
{
    r         


        
4条回答
  •  被撕碎了的回忆
    2020-12-01 02:30

    whenever we are calling web api action and which take [frombody] parameter then input parameter prefix with = for example

    public string GetActiveEvents([FromBody] string XMLRequestString) {
    }
    

    to call above web api action

    1. URI

    2. 2.

    User-Agent: Fiddler

    Content-Type: application/x-www-form-urlencoded

    Host: localhost:54702

    Content-Length: 936

    1. request body is =data

    I hope this will give clear idea.

提交回复
热议问题