Blog Posts for: Razor Pages

Razor Pages tip: Define extra handlers for a Razor Page

10 September 2017

I have been tinkering with Razor Pages a little but, and had a requirement where I wanted to make an AJAX request to the server from a Razor Page. A Razor Page source file typically contains 2 handlers, namely OnGet and OnPost which handles GET and POST requests respectively: public class IndexModel : PageModel { public void OnGet() { // Process GET requests } public void OnPost() { // Process POST requests } } If the handler is an async method, you can also optionally use an Async suffix, for example: