HttpPost not working for public controller

5 months ago
Hi

I am building a new page which should go to the public site, not admin.
I can make it work with method="get" but with method="post" i will always get
"Page Not Found"

This is my form:

@model Nop.Plugin.Admin.ComplaintSystem.Models.ComplaintSearchModel
<form asp-controller="ComplaintPublic" asp-action="CreateOrUpdateUserComplaint" id="frmComplaintPublic" method="post">
    <nop-antiforgery-token />
    <input type="submit" name="test" value="Test" />
</form>


This is my action method:

public class ComplaintPublicController : BasePluginController
.....
[HttpPost]        
public async Task<IActionResult> CreateOrUpdateUserComplaintAsync(ComplaintSearchModel complaintSearchModel)


I have this in my RouteProvider:

public void RegisterRoutes(IEndpointRouteBuilder endpointRouteBuilder)
{
    endpointRouteBuilder.MapControllerRoute(
                            "Plugin.Admin.ComplaintSystem.ComplaintPublic",
                            "ComplaintPublic/CreateOrUpdateUserComplaint",
                            new { controller = "ComplaintPublic", action = "CreateOrUpdateUserComplaintAsync" }
                        );

}


Can anyone point me to what is wrong here?
5 months ago
Just check how this is done in one of our plugins (e.g. Tax.Avalara).
5 months ago
RomanovM wrote:
Just check how this is done in one of our plugins (e.g. Tax.Avalara).


In the Tax.Avalara i dont see any forms with method="post" being submitted which will send a model to the controller.