使用post方法asp.net查询字符串值

时间:2010-08-13 09:41:31

标签: asp.net query-string

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server" method="post">
    <div>

    </div>
    </form>
</body>
</html>



namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Redirect("/WebForm1.aspx?ID=100");
        }
    }
}

第二页

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server" method="post">
    <div>

    </div>
    </form>
</body>
</html>

     protected void Page_Load(object sender, EventArgs e)
            {
                string ID = Request.QueryString["ID"].ToString();
            }

我正在尝试使用post方法获取查询字符串值,但不检索值。 请帮忙

2 个答案:

答案 0 :(得分:1)

使用Request.Form [“var”]

选中此http://msdn.microsoft.com/en-us/library/6c3yckfw.aspx

答案 1 :(得分:1)

或尝试

string ID = Request.Params.Get("ID");
相关问题