为什么我的程序整天报执行子请求时出错
using System;using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Data.Sql;
using
using System.Text;
using System.Windows.Forms;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
FileInfo info = new FileInfo(Server.MapPath("~/news/default.htm"));
TimeSpan span = DateTime.Now.Subtract(info.LastWriteTime);
if (span.Milliseconds < 10)
{
Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
Response.Charset = "GB2312";
Response.Write("Limit 10 seconds!");
}
else
{
string temp = File.ReadAllText(Server.MapPath("~/Template_news.htm"));
StringBuilder template = new StringBuilder(temp);
string title = "我是标题";
string body = "我是Body";
temp = template.Replace("{title}", title).Replace("{body}", body).ToString();
if (!Directory.Exists(Server.MapPath("~/" + Session.SessionID)))
{
Directory.CreateDirectory(Server.MapPath("~/" + Session.SessionID));
}
StreamWriter writer = new StreamWriter(Server.MapPath("~/" + Session.SessionID.ToLower() + "/default.htm"), false, Encoding.GetEncoding("gb2312"));
writer.Write(temp);
writer.Flush();
writer.Close();
}
try
{
Server.Transfer("~/news/default.htm", false);
}
catch (Exception ex) {
MessageBox.Show(ex.Message);
}
}
}
每次我的代码运行到Server.Transfer("~/news/default.htm", false)时,就报
"为/text/news/default.htm 执行子请求时出错 "
请高手指点指点,谢谢