Home > OS >  Razor Pages: Does OnGet Handler "accept" a request body?
Razor Pages: Does OnGet Handler "accept" a request body?

Time:01-27

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.

CodePudding user response:

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.

  •  Tags:  
  • Related