简体   繁体   English

使用ASPX vb.net读取POST变量

[英]Reading POST variables with ASPX vb.net

I need to read variables from POST method in ASPX (VB version). 我需要从ASPX(VB版本)的POST方法中读取变量。

Here the code: 这里的代码:

<!DOCTYPE html>
<html>
    <script runat="server">
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Response.Write("[POST]<br />")
            For Each s As String In Request.Form.AllKeys
                Response.Write("[Request.Form] " & s & ": " & Request.Form(s) & "<br />")
            Next
            Response.Write("[GET] <br />")
            For Each a As String In Request.QueryString.AllKeys
                Response.Write("[Request.QueryString] " & a & ": " & Request(a) & "<br />")
            Next
        End Sub
</script>
<body>
<form action="demo_simpleform.aspx" method="post">
    <input name="infob" type="text" value="POST" id="infob" disabled />
    <input name="TextBox1" type="text" value="" id="TextBox1" />
    <input name="TextBox2" type="password" id="TextBox2" />
    <input type="submit" value="Method POST" />
</form>
<form action="demo_simpleform.aspx" method="get">
    <input name="infoa" type="text" value="GET" id="infoa" disabled />
    <input name="TextBox1a" type="text" value="" id="TextBox1a" />
    <input name="TextBox2a" type="password" id="TextBox2a"/>
    <input type="submit" value="Method GET"/>
</form>
</body>
</html>

Why I cannot read POST variables? 为什么我看不到POST变量? What's wrong? 怎么了? Help me, pls 请帮帮我

I have found solutions (but I don't understand why ...) 我已经找到了解决方案(但是我不明白为什么...)

I must transform FORM action="demo_simpleform.aspx" method="post" into FORM runat="server". 我必须将FORM action =“ demo_simpleform.aspx” method =“ post”转换为FORM runat =“ server”。 Ok, I understand that MUST insert runat="server" parameter (in form declaration and in all objects inside my form) but why I nedd to remove action="demo_simpleform.aspx" method="post" ? 好的,我知道必须插入runat =“ server”参数(在表单声明中以及表单中的所有对象中),但是为什么我想删除action =“ demo_simpleform.aspx” method =“ post”?

Here the working code: 这里是工作代码:

<!DOCTYPE html>
<html>
    <script runat="server">
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Response.Write("[POST]<br />")
            For Each s As String In Request.Form.AllKeys
                Response.Write("[Request.Form] " & s & ": " & Request.Form(s) & "<br />")
            Next
            Response.Write("[GET] <br />")
            For Each a As String In Request.QueryString.AllKeys
                Response.Write("[Request.QueryString] " & a & ": " & Request(a) & "<br />")
            Next
        End Sub
</script>
<body>
<form runat="server">
    <input runat="server" name="infob" type="text" value="POST 2" id="infob" disabled />
    <input runat="server" name="TextBox1" type="text" value="" id="TextBox1" />
    <input runat="server" name="TextBox2" type="password" id="TextBox2" />
    <input runat="server" type="submit" value="Method POST 2" />
</form>
<form action="demo_simpleform.aspx" method="get">
    <input name="infoa" type="text" value="GET" id="infoa" disabled />
    <input name="TextBox1a" type="text" value="" id="TextBox1a" />
    <input name="TextBox2a" type="password" id="TextBox2a"/>
    <input type="submit" value="Method GET"/>
</form>
</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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