Click here to Skip to main content
15,894,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am writing a website in ASP .Net Core 3. I want to implement a method which will take 2 parameters in the POST query. The data sent to the server should be plain text, not JSON, e.g.

request POST

example.com/api

the content of the task

message_1="content"&message_2="content_2"

<pre>The following function calls but the parameters are null.
How is it going to change it?


What I have tried:

C#
[HttpPost]
[Route("/api")]
public IActionResult Api(string message_1, string message_2)
 {
    return View();
 }
Posted
Updated 22-Mar-21 5:32am

1 solution

I used manual query reading.

C#
using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
            {
                return = await reader.ReadToEndAsync();

        
                }


problem solved
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900