| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2166 人关注过本帖
标题:为什么我的程序整天报执行子请求时出错
取消只看楼主 加入收藏
linwen0914
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-6-10
收藏
 问题点数:0 回复次数:0 
为什么我的程序整天报执行子请求时出错
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 执行子请求时出错 "
请高手指点指点,谢谢
搜索更多相关主题的帖子: 请求 
2008-06-10 10:20
快速回复:为什么我的程序整天报执行子请求时出错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.040919 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved