NOP 4.3: Plugin route is not working for [HttpPost]

4 个月 前
The route is working for GET but not for POST.
Here is my code:

RouteProvider.cs:

 public partial class RouteProvider : IRouteProvider
    {      
        public void RegisterRoutes(IEndpointRouteBuilder endpointRouteBuilder)
        {                        
endpointRouteBuilder.MapControllerRoute("Plugin.Payments.Tranzila.SetTransactionStatus", "Plugins/PaymentTranzila/SetTransactionStatus",
                 new { controller = "PaymentTranzila", action = "Test1" });


endpointRouteBuilder.MapControllerRoute("Plugin.Payments.Tranzila.SetTransactionStatus", "Plugins/PaymentTranzila/Test",
                new { controller = "PaymentTranzila", action = "Test" });
        }
      
        public int Priority => -1;
    }



Controller:

      
 [HttpPost]
        public IActionResult Test1()
        {            
            return null;
        }

        public IActionResult Test()
        {
            return null;
        }
4 个月 前
The problem was:  [AutoValidateAntiforgeryToken]
1 个月 前
Hi, Can you explain what's the problem and the solution?
I have the same problem with the callback Action method in the payment plugin in NopCommerce 4.0 (Bank redirect User with post method to call back URL and post some values). when I use [HttpPost] routing not found my action and when to remove that, my action is called but form values are null.
I test some attributes but routing is not found my action yet.
       //[HttpPost]
       //[AutoValidateAntiforgeryToken]
       //[AdminAntiForgery(true)]
        public ActionResult CallBack(IFormCollection form)
        {....
1 个月 前
This is how I did it:

My plugin controller:

        
        [HttpPost]
        public IActionResult PaymentSuccess() {
            var paymentIndex= Request.Form["paymentIndex"];
       }
        


My RouteProvider.cs:
      public void RegisterRoutes(IRouteBuilder routeBuilder)
        {

            routeBuilder.MapRoute("Plugin.Payments.Tranzila.PaymentSuccess", "Plugins/PaymentTranzila/PaymentSuccess",
                new { controller = "PaymentTranzila", action = "PaymentSuccess" });


I am not using
[AutoValidateAntiforgeryToken]
1 个月 前
Thank you for sharing this.
1 个月 前
With pleasure mate :)
please let me know if I can be of any further help