是否可以在 ASP.NET MVC 中重定向 HTTPPost?
在我的 MVC 应用程序中,我有一个视图,用于收集基本表单中的用户输入。当用户点击提交时,它会发布到我的 MVC 应用程序,我在其中执行数据库操作,但随后需要通过另一个 HTTP Post 将值从表单重定向到外部 URL。
真实场景如下。
1. 我显示一个购物车页面。该视图包含一个 Html 表单,其中包含财务详细信息(即商品、单价、数量和总计)。它还收集账单和运输信息。
2. 当用户点击提交时,表单值将包含在发布到我的 MVC 应用程序中。此时,我需要记录即将收取付款,因此我将一个条目写入数据库。然后我需要重定向到将进行信用卡处理的第三方网站。此重定向必须是 HTTP Post,其中包含与我的原始表单相同的表单值。
3. 用户将看到第三方信用卡处理页面。它处理对我的重定向。
谢谢。
In my MVC application I have a View that collects user input in a basic Form. When the user hits submit it Posts to my MVC Application where I perform a database operation but then need to redirect the values from the Form to an external URL via another HTTP Post.
The real scenario is as follows.
1.
I display a Shopping Cart Page. The View contains an Html Form which contains financial details (ie. items, unit price, quanitities and a total). As well it collects billing and shipping information.
2.
When the user hit the submit the Form values are included in a Post to my MVC Application. At this point I need to record that a payment is about to be collected so I write an entry to my database. Then I need to redirect to a third party site that will do the credit card processing. This redirect must be an HTTP Post that includes the same Form Values from my original Form.
3.
The user will be presented with the third party credit card processing page. It handles the redirect to me.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当用户首次提交表单时,您可以进行 Ajax 调用。该调用将写入您的数据库,将数据(如果需要)返回到页面,然后回调会将页面发布到第三方。
You could make an Ajax call when the user first submits the form. The call would write to your database, return data (if needed) to the page, then the callback would post the page to the third party.