Well,
I have written JsonResult funtion. But i get the following error:
CS0103 C# The name \'Json\' does not exist in the current context
Page must be derived from Controller class to Json () and JsonResult() part by using Microsoft.AspNetCore.Mvc;
If you are using Razor page model then you can face this issue. I got it after too much time spending.
You can also change your page derived from Controller instead of pagemodel like this public class User: Controller