如何从HTML一个表单POST给ASPX页面 [英] How to POST a FORM from HTML to ASPX page

查看:551
本文介绍了如何从HTML一个表单POST给ASPX页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何上传表单从HTML页面和ASPX页面(2.0),并能够读取值?

How do I post a form from an HTML page to and ASPX page (2.0) and be able to read the values?

我当前使用的会员提供者和一切工作正常的ASP.NET网站。用户可以从网页的Login.aspx登录。

I currently have an ASP.NET site using the Membership provider and everything is working fine. Users can log in from the Login.aspx page.

我们现在希望能够让用户直接从其他网站登录 - 这基本上是一个静态的HTML页面。用户需要能够将此HTML页面中输入自己的姓名和密码,并将其张贴到我的Login.aspx页面(即我可以再手动登录它们)。

We now want to be able to have users log in directly from another web site--which is basically a static HTML page. The users need to be able to enter their name and password on this HTML page and have it POST to my Login.aspx page (where I can then log them in manually).

是否有可能从HTML表单传递值ASPX?我已经试过各种与Request.Form.Keys集合总是空的。我不能使用HTTP GET,因为这些凭据,并不能查询字符串传递。

Is it possible to pass form values from HTML to ASPX? I have tried everything and the Request.Form.Keys collection is always empty. I can't use a HTTP GET as these are credentials and can't be passed on a query string.

我知道的唯一方法是一个iframe。

The only way I know of is an iframe.

推荐答案

这是的非常的可能。我嘲笑了3页这应该给你一个概念证明:

This is very possible. I mocked up 3 pages which should give you a proof of concept:

.aspx页面中:

<form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:TextBox TextMode="password" ID="TextBox2" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" />
    </div>
</form>

背后code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    For Each s As String In Request.Form.AllKeys
        Response.Write(s & ": " & Request.Form(s) & "<br />")
    Next
End Sub

独立的HTML页面:

Separate HTML page:

<form action="http://localhost/MyTestApp/Default.aspx" method="post">
    <input name="TextBox1" type="text" value="" id="TextBox1" />
    <input name="TextBox2" type="password" id="TextBox2" />
    <input type="submit" name="Button1" value="Button" id="Button1" />
</form>

...并预期它反刍表单值。如果这不是工作,因为其他人则建议,使用流量分析工具(小提琴手,空灵),因为事情很可能不会在那里你期待的。

...and it regurgitates the form values as expected. If this isn't working, as others suggested, use a traffic analysis tool (fiddler, ethereal), because something probably isn't going where you're expecting.

这篇关于如何从HTML一个表单POST给ASPX页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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