简体   繁体   中英

HTTP POST to iFrame

I'm trying to integrate my website with a third party white label website, which can hosted within an iFrame from my website.

In order for the iFrame to load the website correctly, I need to issue a HTTP POST with credentials to a source url, passing the credentials as a querystring. The server will then respond, after which I then need to set the iFrame src attribute to the same URL I posted to, and then reload the page.

So, to recap, my HTTP POST should be to the following URL, dynamically setting in the id parameter from my codebehind before posting:

https://cads.mobile.com/WhiteLabelSite/Default.aspx?id=1234-1234-1234-1214

After the response, my site needs to redirect the iframe to that exact same URL. So I need to set the iFrame src to the dynamic URL before redirecting..

I'm not sure how to do this...sigh

  1. create a new page called sitePostRedirect.aspx
  2. the purpose of that will be to make the HTTP POST action and then redirect to the required URL.
  3. You can make the post using a form and a submit button click emulation or any other method.
  4. Direct your IFrame to use sitePostRedirect.aspx wich will handle everything from that point.

sitePostRedirect.aspx:

<form id="myForm" method="post" action="http://someurl.com" runat-"server"/>
   <asp:hiddenfield id="ValueHiddenField" value="" runat="server"/>
</form>

<script>
  $(document).ready(function(){
     $('#myForm').submit();
  });
</scrip>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM