Redirect with POST parameters in MVC 4 for Payment Gateway Integration

后端 未结 3 1666
难免孤独
难免孤独 2021-01-20 20:14

I am trying to do a payment gateway integration using mvc4 in razor. In that i need to call a page with prefilled post form.

Using the below method, I am forming th

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-20 20:29

    I suggest you to create an Action with form which receives a Model in parameters. Then, just pass model when you redirect to this Action

    [HttpPost]
    public ActionResult OrderSummary()
    {
        return RedirectToAction("OrderForm", new { HashData = hashData });
    }
    
    [HttpGet]
    public ViewResult OrderForm(string hashData)
    {
        OrderFormModel model = new OrderFormModel();
        model.HashData = hashData;
        return View(model);
    }
    
    [HttpPost]
    public ActionResult OrderForm(OrderFormModel model)
    {
        if(ModelState.IsValid)
        {
            // do processing
        }
    }
    

提交回复
热议问题