Understanding POST Receipts on C#.NET

Asked 2 years ago, Updated 2 years ago, 52 views

We are currently developing at C#.
Google Chrome extensions have a function called "Send data to the URL specified as POST in JSON format," and I would like to use the data sent.
Therefore, I would like to send the data and obtain and use the data in C#.
I did some research and wrote programs in ASP.NET and HttpListner classes, but I don't know how to do xx when it is sent.
I would appreciate it if someone could tell me.




[Development environment]

c#

2022-09-30 21:27

1 Answers

You cannot create a program that "automatically starts when POST is sent".Because regular applications need to monitor specific ports to handle HTTP requests.Therefore, if you are using HttpListener, the correct implementation is to wait blocking until at least the first request.

Also, when using the ASP.NET family, the framework will handle the request until it starts, so programmers only need to implement actions and form events that correspond to specific URLs.

Regardless of which way it is implemented, it is not different in principle from using HTML page Form.First, check if you can receive requests at that level.Also, JSON is stored in the request body, so you can read the payload by passing the Stream obtained from HttpRequest.GetBufferedInputStream() to an appropriate serializer such as Json.NET.


2022-09-30 21:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.