Reputation: 48
(Using ASP.NET Core 3.1 - Razor Pages web application)
I am trying to trigger OnPost method which is in Areas >> Login >> Pages >> Index.cshtml.cs Razor Page. Somehow, it triggers OnGet method but when I try to post a form, it didn't trigger OnPost method.
Index.cshtml.cs
namespace WebApplication1.Areas.Login.Pages
{
public class IndexModel : PageModel
{
public void OnGet()
{
//triggering
}
public void OnPost()
{
//not triggering
}
}
}
Index.cshtml
@page
@model WebApplication1.Areas.Login.Pages.IndexModel
@{
}
<form method="post">
<input name="UserId" class="form-control" />
<input type="submit" value="Create" class="btn btn-primary" />
</form>
Note: If I am not using Areas, OnGet and OnPost working fine.
I have tried below but none of them worked for me:
Upvotes: 1
Views: 2616