I have been stuck with two problems in ASP.NET CORE RAZOR PAGES and I didn't find any content about it.
Problem 1: I have been trying to do an overload on my page component, but it looks like it's not possible, to make it works, I'm, using a nullable parameter on my method, but I do not know if this is the best way to do it, there's a better way?
What I have working:
// For New Item or Edit Item
public IActionResult OnGetModal(int? squid)
What I wanted:
// For new Item
public IActionResult OnGetModal()
// For Edit Mode
public IActionResult OnGetModal(int squid)
NOTE: If instead this unique method with a nullable parameter, I use two methods 1 method without parameter and another method with this int parameter, I got an error because I have multiple handlers.
Problem 2: I have 2 methods with the same parameter name, and I got an error when I try to refer to this handler.
Method 1:
public IActionResult OnGetModal(int? squid)
Method 2:
public bool OnPostActivateDeactivate(int squid, bool isActive)
Here I'm trying to access the method Modal:
URL: ?handler=modal&squid=1001
Error: InvalidOperationException: Unsupported handler method return type 'System.Boolean'.
How do I solve these problems or what would be the best way to do it?
actionResult Method
because its return View not a values. You need to create another Method – Kiran Joshi