1

When fetching a razor page, is it possible to pass a Request-Body to it? When the OnGet handler is called, this.Request.Body or this.HttpContext.Request.Body seem to be empty: OnGet Body empty

This doesn't seem to be the case for OnPost handler (duh): enter image description here

In my opinion using Query-Parameters instead of a Request-Body is more suitable for a GET-Request, however there is the complaint that the URL would be too long when calling the page.

Question is, can I read the Request-Body in the OnGet handler somehow? Any help is much appreciated.

Yiyi You
  • 16,875
  • 1
  • 10
  • 22
Fanta
  • 27
  • 5

1 Answers1

2

can I read the Request-Body in the OnGet handler somehow

No,You can send a request body with Get request,bu the requst body will be ignored.So if you want to send a request body,you can use Post or Put request.

Yiyi You
  • 16,875
  • 1
  • 10
  • 22
  • Thank you! I looked up the documentation but wasn't able to find anything related. Can you perhaps point me somewhere? :) – Fanta Jan 27 '22 at 09:02
  • https://stackoverflow.com/questions/978061/http-get-with-request-body – Yiyi You Jan 27 '22 at 09:06