当时的情况是这样的:
a.aspx页面 执行一个URL字符串访问b.aspx 然后 b页面返回一个值给a
a.aspx.cs的一段代码
代码如下:
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;//20秒超时
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页面代码:
代码如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
b.aspx.cs代码如下:
代码如下:
public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("你好 哈哈!");
新闻热点
疑难解答
图片精选