日期:2014-05-18  浏览次数:20661 次

初学者提问
first.htm
<html>
<head> <title>

</title>
</head>
<body>
<center>
<form   action= "get1.aspx "   method= "post "   >
<input   type= "text "   name= "nickname "> <br>
<input   type= "submit "   value= "发送 ">
</form>
</center>
</body>
</html>


get1.aspx
<%@   Page   Language= "C# "   ContentType= "text/html "   ResponseEncoding= "gb2312 "   %>
<!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>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 无标题文档 </title>
</head>
<body>
<%
String   Nickname=Request.Form[ "nickname "];
Response.Write(Nickname);
%>
</body>
</html>
为什么get1.aspx接收不到first.htm传来的nickname,如果我把post改成get,
Request.Form改成Request.QueryString就可以接收到

------解决方案--------------------
post提交:
<%
String Nickname=Request.Form[ "nickname "].ToString();
Response.Write(Nickname);
%>
或:
<%
String Nickname=Request.Form.Get( "nickname ").ToString();
Response.Write(Nickname);
%>
get提交:

<%
String Nickname=Request.QueryString[ "nickname "].ToString();
Response.Write(Nickname);
%>