在另一个页面中读取 Response.write
我有一个页面 www.senderdomain.com/sender.aspx,我需要从该页面将字符串写入其他域 www.receiverdomain.com/receiver.aspx 中的另一个页面>
在 sender.aspx 中,我已经编写了
Response.Write("Hello");
Response.Redirect(Request.UrlReferrer.ToString());
它被重定向到相应的receiver.aspx 页面,但我不确定如何在receiver.aspx 页面中获取文本“Hello”。任何人都可以帮忙吗?
I have a page www.senderdomain.com/sender.aspx, from which i need to write a string to another page in other domain www.receiverdomain.com/receiver.aspx
In sender.aspx i have written
Response.Write("Hello");
Response.Redirect(Request.UrlReferrer.ToString());
It gets redirected to respective receiver.aspx page, but I am not sure how to get the text "Hello" in receiver.aspx page. Can any pl help on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您似乎在 Sender.aspx 上有一个值,需要在receiver.aspx 中显示。您可以这样做。
编辑
如果域发生更改,直接的简单方法是传递查询字符串中的值。
您可能会发现代码模式保持不变,并且用于将值从 Session 传输到 QueryString 的容器发生了变化。
EDIT2
如果在这种情况下您担心安全性并且您不希望公开值 [
"Hello"
],那么这里有另一种方法可以帮助您。在此解决方案中,我们首先将页面重定向到接收者,然后从接收者向发送者询问值。首先我们要编写接收器的代码。在sender.aspx中
It seems you have a value on Sender.aspx that you need to display in receiver.aspx. This is how you can do it.
EDIT
In case of change in domain, immediate easy way is to pass the value in query-string.
You may observe that the code pattern remains the same and container that is used to transfer the value changes from Session to QueryString.
EDIT2
If security is a concern with you in this case and you don't wish to expose the value [
"Hello"
], then here comes another way that can help you. In this solution we will first redirect the page to receiver and then from receiver it shall ask for the value to sender. So first we'll write the code for receiver.And in the sender.aspx
您需要传递 url 中的值或将其发布到跨页面回发中。
对于安全的跨域通信,请查看 SAML(安全断言标记语言)。它是跨域边界安全传递信息的标准方法。它最常用于单点登录场景,但它可以用于安全地传递数据。您使用证书吗?您使用什么类型的加密?
另一种选择是将状态保存到两个域均可访问的数据库或文件系统中。
You need to pass the value in the url or post it in a cross page postback.
For secure cross domain communication, take a look at SAML (Security Assertion Markup Language). It is a standard way of passing information securely across domain boundaries. It is most often used in Single Sign On scenarios, but it can be used to pass data securely. Are you using certificates? What type of encryption are you using?
Another option would be to save state to a database or filesystem that is accessible to both domains.
在查询字符串中传递数据,因为不能这样做,
例如
在接收器页面访问查询字符串数据,将解决您的问题。
pass data in query string because can not do like this
for example
And in receiver page access querystring data, will resolve your issue.
Response.Redirect
方法将废弃您写入页面的所有内容,并将其替换为重定向页面,因此您无法随重定向一起发送任何内容。在重定向中发送数据(在不同域和不同服务器之间工作)的唯一选项是将其放入 URL 本身。示例:
另一个选项是输出包含自动发布到目标的表单的页面:
您可以在接收页面上使用
Request.Form["msg"]
来获取值。The
Response.Redirect
method will scrap everything that you have written to the page, and replace it with a redirection page, so you can't send any content along with the redirect.The only option to send data along in a redirect (that works between differnt domains and different servers) is to put it in the URL itself. Example:
Another option is to output a page containing a form that is automatically posted to the destination:
You can use
Request.Form["msg"]
on the recieving page to get the value.如果您想避免以后出现各种问题,请不要使用内置的 URL 编码。
上面支持 unicode 以及几乎所有内容。
Don't use the built-in URL encode, if you want to avoid all sorts of problems later.
The above supports unicode, and pretty much everything.