我是MVC的新手。 实际上,我在ASP.Net中有一个场景,我submitting data (包含Amount,RedirectURL等)提交到URL (支付网关),如下所示:
<form id="form1" runat="server" method="post" action="https://test2pay.ghl.com/IPGSG/Payment.aspx"> <div> <%=eGHLPurchaseItems%> <input type="submit" value="Pay Now" /> </div> </form>它将redirect to that payment gateway page ,成功交易后,我将被redirected back to my application页面,其中包含一些extra status codes 。
我正在通过HttpContext.Current.Request["TransactionType"];处理这些返回状态值HttpContext.Current.Request["TransactionType"];
现在,我需要在MVC中这样做,但我唯一的困惑是如何提交表单。
我在MVC中尝试过:
@using (@Html.BeginForm("https://test2pay.ghl.com/IPGSG/Payment.aspx", null, FormMethod.Post)){ <button type="submit" class="btn btn-lg b-primary">Proceed to Payment</button> }但是,我正被重定向到此URL:
http://localhost:62414/Billing/https%3a/test2pay.ghl.com/IPGSG/Payment.aspx任何人都可以帮助我如何使用MVC中的一些数据提交表单?
I'm new to MVC. Actually, I've a scenario in ASP.Net where I'm submitting data(which contains Amount,RedirectURL etc) to a URL(Payment Gateway) like this :
<form id="form1" runat="server" method="post" action="https://test2pay.ghl.com/IPGSG/Payment.aspx"> <div> <%=eGHLPurchaseItems%> <input type="submit" value="Pay Now" /> </div> </form>and it will redirect to that payment gateway page and after successful transaction, I will be redirected back to my application page with some extra status codes.
I'm handling those return status values by HttpContext.Current.Request["TransactionType"];
Now, I need to do that in MVC, but my only confusion is how to submit form.
I've tried in MVC by using :
@using (@Html.BeginForm("https://test2pay.ghl.com/IPGSG/Payment.aspx", null, FormMethod.Post)){ <button type="submit" class="btn btn-lg b-primary">Proceed to Payment</button> }But, I'm getting redirected to this URL :
http://localhost:62414/Billing/https%3a/test2pay.ghl.com/IPGSG/Payment.aspxCan anyone pls help me how I can submit a form using some data in MVC?
最满意答案
为标签或使用创建html
你的控制器就像
ViewBag.CustId = "101"; ViewBag.Email = "cust@sss.sss";和观点
@Html.BeginForm(null, null, FormMethod.Post, new {@action="https://test2pay.ghl.com/IPGSG/Payment.aspx"}) { @Html.Hidden("id", @ViewBag.CustId); @Html.Hidden("email", @ViewBag.Email); <button type="submit" class="btn btn-lg b-primary">Proceed to Payment</button> }由于您尝试重定向到外部URL,因此将Action和Controller设置为null。
Either create html for tag or use
Your controller be like
ViewBag.CustId = "101"; ViewBag.Email = "cust@sss.sss";And View
@Html.BeginForm(null, null, FormMethod.Post, new {@action="https://test2pay.ghl.com/IPGSG/Payment.aspx"}) { @Html.Hidden("id", @ViewBag.CustId); @Html.Hidden("email", @ViewBag.Email); <button type="submit" class="btn btn-lg b-primary">Proceed to Payment</button> }Since you are trying to redirect to external url, set Action and Controller to null.
更多推荐
发布评论