关于在ASP.NET中实现POST发送数据的问题,我用的是孟子e章的原码

imimp 2003-08-24 04:31:01
我现在需要在ASP.NET程序中向一个ASP发送数据
我用了孟子e章的原码(http://xml.sz.luohuedu.net/xml/ShowDetail.asp?id=ATV1GLXT-65FF-4M82-CT5U-B1J65D3ZN2OK)
现在的问题是
我想发送后直接转到那个接收的ASP页面,也就是像FORM提交那样
而不是直接Redirect过去
请问有什么方法?

还有,如果接收的ASP中没有
If Request.ServerVariables("REQUEST_METHOD")= "POST"
也可以正常接收吗?因为ASP不是我做的,我不知道他有没有这个判断
...全文
115 37 打赏 收藏 转发到动态 举报
写回复
用AI写文章
37 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2003-08-27
  • 打赏
  • 举报
回复
then you have no choice but write a form to the client side and submit the data to the 银行 from there

<form name="form1" action="银行.asp" method="post">
<input type=hidden name=银行account value="123123">
<input type=hidden name=... ..>
...
</form>
<script language=javascript>
function window.onload()
{
document.form1.submit();
}
</script>

frankly, doesn't feel your 银行 is right. I had done e-commerce before and all transactions were done on the backend
imimp 2003-08-27
  • 打赏
  • 举报
回复
谢谢saucer
我的情况应该是不可能使用HttpWebResponse,因为不仅仅是银行分析我post过去的数据然后显示给用户的问题,银行在收到我的数据之后,用户还必须在银行那边进行输入,银行根据我post过去的数据和用户在他页面的输入一起操作,而这些操作不可能让我知道,也不可能在我这边完成。
其实现实的情况就是:银行接收我post(规定只能使用form post方法)过去的数据,而且还要求我把用户引导到银行的输入页面,就这么简单。而且银行的接口不能改变,也就是我一定要这么做。所以我不能用redirect,这样用户在我这边的输入和在银行的输入脱节,银行无法正确操作。
imimp 2003-08-27
  • 打赏
  • 举报
回复
>>>>>doesn't feel your 银行 is right

不接触你不知道,接触了你就知道为什么中国的银行没有希望

i feel they are so stupid

有一些很明显的漏洞,地球人都可以知道他们会说希望用户素质高一点或者没有发现而不去作出修改

不管如何,非常感谢saucer
还有所有上面帮忙的朋友,特别是panyee(快乐王子)
imimp 2003-08-26
  • 打赏
  • 举报
回复
不做session判断的,但是里面怎么操作我post过去的数据我不知道
gOODiDEA 2003-08-26
  • 打赏
  • 举报
回复
用transfer,请参考下面的列子:

//////////////////////////////////////////////
firstpage.aspx
//////////////////////////////////////////////
<%@ Page Language="C#" Inherits="FirstPageClass" %>

<html>
<head>

</head>

<body>

<form runat="server">
First Name:
<asp:TextBox id="first"
runat="server"/>
<br/>
Last Name:
<asp:TextBox id="last"
runat="server"/>
<br/>
<asp:Button
id="Button1"
OnClick="ButtonClicked"
Text="Go to second page"
runat=server />
</form>

</body>

</html>


//////////////////////////////////////////////////
firstpage.aspx.cs
//////////////////////////////////////////////
using System;

public class FirstPageClass : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox first;
protected System.Web.UI.WebControls.TextBox last;
protected System.Web.UI.WebControls.Button Button1;

public string FirstName
{
get
{
return first.Text;
}
}

public string LastName
{
get
{
return last.Text;
}
}

void ButtonClicked(object sender, EventArgs e)
{
Server.Transfer("secondpage.aspx");
}
}

//////////////////////////////////////////////////
secondpage.aspx
//////////////////////////////////////////////////
<%@ Page Language="C#" Inherits="SecondPageClass" %>
<%@ Reference Page="firstpage.aspx" %>

<html>

<head>

</head>

<body>

<form runat="server">

Hello <%=fp.FirstName%> <%=fp.LastName%>

</form>

</body>

</html>
//////////////////////////////////////////////////
secondpage.aspx.cs
//////////////////////////////////////////////////
using System;

public class SecondPageClass : System.Web.UI.Page
{

protected System.Web.UI.WebControls.Label DisplayLabel;
public FirstPageClass fp;

void Page_Load()
{
if (!IsPostBack)
{
fp = (FirstPageClass) Context.Handler;
}
}

}
panyee 2003-08-26
  • 打赏
  • 举报
回复
test.asp作了什么样的判断你知道吗?如果判断了session,那从服务器上post,
再让客户端显示之后的页面应该是不行的, 因为客户端GET url时没有相应的sessionid
panyee 2003-08-26
  • 打赏
  • 举报
回复
test.asp作了什么样的判断你知道吗?如果判断了session,那从服务器上post,
再让客户端显示之后的页面应该是不行的, 因为客户端GET url时没有相应的sessionid
imimp 2003-08-26
  • 打赏
  • 举报
回复
本来如果使用get方法直接在url后面传参数给test.asp就可以直接到test.asp了,可是规定只能使用post,真不知道怎么办了阿
panyee 2003-08-26
  • 打赏
  • 举报
回复
服务端可以在post之后用
Response.Redirect("http://otherhost/test.asp");

asp页面中作了什么判断你可知道 ? 如果有session的判断,你在服务端直接提交,切换

在客户端是没有相应的sessionid
imimp 2003-08-26
  • 打赏
  • 举报
回复
假设现在有一个form,action是一个接收的asp页面,比如test.asp,form上有一些输入,然后有一个submit按钮。我输入后按submit按钮,页面就会跳转到test.asp,test.asp做处理后显示处理的结果

现在我想:
用户在form输入一些信息,提交的时候不直接提交给test.asp,而是由我先对这些输入进行处理,处理完后我在后台直接post给test.asp,这些数据用户看不见。然后test.asp对我post给它的数据进行处理,然后显示处理结果。对用户来说,他感觉不到我在中间作了处理,而是以为他直接提交到test.asp

因为用户的输入必须进行编码和加密,不能直接发送,而test.asp又不是我做的,所以我必须在中间进行处理,而我要让用户感觉不到我做了处理,否则我处理完之后还要让他们再提交一次,会被骂死的
saucer 2003-08-26
  • 打赏
  • 举报
回复
I would suggest you do the data submission on the server side with HttpWebRequest/HttpWebResponse, parse the response from your 银行, and incorporate it into the page you are returning to the user

if the 银行's response is a redirection, catch that location by parsing the headers with HttpWebRequest.AllowAutoRedirect=false, then do a Response.Redirect in your code
panyee 2003-08-26
  • 打赏
  • 举报
回复
如果要在客户端显示那种效果,那并不能采用服务器去post的方式

做一个隐藏的iframe中去post数据,成功之后,在top框架上显示新的那个页面
imimp 2003-08-26
  • 打赏
  • 举报
回复
我取得 byte[] response还是我这边的呀,我需要在浏览器地址栏上显示的也是asp那个页面的url
就相当于action是哪个asp页面
然后我点击submit按钮过去一样的效果
怎么实现?
imimp 2003-08-26
  • 打赏
  • 举报
回复
没有找到一个好的解决方法阿
现在似乎只能生成一个hidden form然后用javascript自动submit了

我就是怕hidden form在submit的时候突然submit被取消了,这样不是可以在IE的原文件里看到我要post的数据了吗?这个ssl也控制不了啊?
孟子E章 2003-08-26
  • 打赏
  • 举报
回复
好了吗?
孟子E章 2003-08-26
  • 打赏
  • 举报
回复
好了吗?
panyee 2003-08-26
  • 打赏
  • 举报
回复
既然已经用ssl那已经是较安全的了

像集成验证,模拟登录,一般都是在客户端进行,而不是在服务端

panyee 2003-08-26
  • 打赏
  • 举报
回复
用了ssl还怕什么
imimp 2003-08-26
  • 打赏
  • 举报
回复
非常感谢saucer
1.redirect // B/page.asp can not receive data from A
2.form.submit() // 就算在window.onload里就submit是不是还是有可能通过源文件看到我要发送的数据???
3.js // B/page.asp只能通过post方式接收我的数据

我现在已经是使用SSL了,我之所以不愿意使用form.submit就是觉得有可能hidden form会在submit被cancel掉之后里面的数据给人看见了,不过现在看来好像只能使用这种方法了

非常感谢大家
明天结贴
为什么我加超过100分就不让我加呢?
我看别人有的是200分的啊
怎么加上去得呢?



saucer 2003-08-26
  • 打赏
  • 举报
回复
see, you have two unrelated servers (A and B) and one client, this client submits a request to one server A, for the client to get a response from server B directly, the request needs to come from the client's browser:

1. either A calls Response.Redirect to B/page.asp, so the browser will send a request to B and get back a response

2. A writes some a form to the browser and calls form.submit() to submit the data to B/page.asp

3. A writes some javascript, window.location.href="B/page.asp";

otherwise, use server side processing (A->B), then redirect the client to a page on B, or output the response from B to the clietn directly


>>>要求保密性比较高

use SSL
加载更多回复(17)

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧