有可能是转到了http://localhost/b.aspx,也就是http://localhost:8080/b.aspx,建议
<form id="Form1" method="post" action="http://localhost:801/b.aspx">
<form id="Form1" method="post" action="http://localhost:801/b.aspx">
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;
}
}}