The current situation was as follows:
A. The aspx page executes a URL string to access B. aspx, and then the B page returns a value to
A. aspx. cs code segment
Copy codeThe Code is as follows:
String result = "";
String url = "http: // localhost: 1759/textWeb/B. aspx ";
Result = exec_url (url );
Label1.Text = result;
Public string exec_url (string url)
{
String result = "1 ";
WebRequest request = WebRequest. Create (url );
Try
{
Request. Timeout = 20000; // Timeout in 20 seconds
WebResponse response = request. GetResponse ();
Stream resStream = response. GetResponseStream ();
StreamReader sr = new StreamReader (resStream );
Result = sr. ReadToEnd ();
Sr. Close ();
ResStream. Close ();
}
Catch
{
Return "1 ";
}
Return result;
}
B. aspx page code:
Copy codeThe Code is as follows:
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
</Div>
</Form>
</Body>
</Html>
B. The aspx. cs code is as follows:
Copy codeThe Code is as follows:
Public partial class test: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
Response. Write ("Hello, haha! ");
}
}
Running time: the Label content is displayed normally for the first time, but the prompt is displayed when you click the button again without refreshing the page.
System. Web. HttpException: The status information of this page is invalid and may be damaged.
Cause:
It turns out that when the label loads the content for the first time, the content is B. aspx.
<Form>
Hello, haha!
</Form>
The principle of clicking again should be like this:
<Form>
Hello, haha!
<Form>
Hello, haha!
</Form>
</Form>
So an error occurred!
Solution: remove the form label in B. aspx.