RazorPage typically return void, Task, IActionResult, such as
public Task OnGet() { }
public Task<IActionResult> OnGet() { }
It's also possible having a handler returning Json, like
public Task<JsonResult> OnGetAlso() { }
But there are scenarios where I want the handler to return raw string, but I couldn't find an easy way to do this.
public Task<string> OnGetSomeString()
{ return "something"; }
But I always get errors Unsupported handler method return type. Is this possible? Thanks
Use a ContentResult
to return string
content:
public IActionResult OnGetSomeString()
{
return Content("something");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With