如何:跨站点张贴和重定向在ASP.NET web表单 [英] How to: Cross-Site posting and redirection in ASP.NET webforms

查看:145
本文介绍了如何:跨站点张贴和重定向在ASP.NET web表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情景:

我手头上的任务是使不同组织/网站之间的单点登录解决方案。我开始作为一个组织的网站身份验证的用户,转换的具体信息为XML文档,加密与三重DES文件,并发送了作为变量后到第二个组织的登录页面。

The task I have at hand is to enable a single-signon solution between different organizations/websites. I start as an authenticated user on one organization's website, convert specific information into an Xml document, encrypt the document with triple des, and send that over as a post variable to the second organizations login page.

问:

一旦我有我的XML数据打包,我怎么编程执行后的第二个网站,并让用户的浏览器重定向到第二个网站也是如此。

Once I have my xml data packaged, how do I programmatically perform a post to the second website and have the user's browser redirected to the second website as well.

这应该表现就像有像的形式:

This should behave just like having a form like:

行动=htt​​p://www.www.com/posthere方法=后

...并有像一个隐藏的文本字段:

... and having a hidden text field like:

输入类型=隐藏值=我的加密的XML

这是被写入asp.net 2.0 web表单。

This is being written in asp.net 2.0 webforms.

-

编辑:尼克问为什么HTML表单我上面描述将无法工作。答:我有超过任一站点没有控制权;我建设的中间人,使这一切发生。网站1转发用户,我制作的页面,我必须建立在XML,然后转发给站点2站点1不希望用户知道我的网站,重定向应该是透明的。

Nic asks why the html form I describe above will not work. Answer: I have no control over either site; I am building the "middle man" that makes all of this happen. Site 1 is forwarding a user to the page that I am making, I have to build the XML, and then forward it to site 2. Site 1 does not want the user to know about my site, the redirect should be transparent.

我上面所描述的过程是什么,双方(站点A和站点B)的任务。

The process I have described above is what both parties (site A and site B) mandate.

推荐答案

发送回包含从隐藏的输入文档并包括onload事件处理程序,立即帖子的形式向其他网站。使用jQuery的的document.ready()解决了之前发生后,虽然也有其他方法可以做到这一点没有jQuery的DOM中是否加载了问题。您可能要包括在屏幕上的效果,用户将很快重新定向,并提供一个链接,也做岗位上的一些小的消息

Send back a document that contains the from with hidden input and include an onload handler that posts the form immediately to the other site. Using jquery's document.ready() solves the issue of whether the DOM is loaded before the post occurs, though there are other ways to do this without jquery. You might want to include some small message on the screen to the effect that the user will be redirected shortly and provide a link which also does the post

...headers left out...

<script type='text/javascript'>

$(document).ready( function() {
   $('form:first').submit();
 });
</script>

<body>
   <form action='othersiteurl' method='POST'>
       <input type='hidden' value='your-encrypted-xml" />
   </form>
</body>

这篇关于如何:跨站点张贴和重定向在ASP.NET web表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆