| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2161 人关注过本帖
标题:为什么我的程序整天报执行子请求时出错
只看楼主 加入收藏
linwen0914
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-6-10
收藏
 问题点数:0 回复次数:1 
为什么我的程序整天报执行子请求时出错
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
hebingbing
Rank: 6Rank: 6
来 自:黄土高坡
等 级:贵宾
威 望:27
帖 子:3417
专家分:371
注 册:2007-10-22
收藏
得分:0 
Server.Transfer是将同一个服务器上的A页面的控制权交给B页面,在转移的过程中,不能离开服务器,你的上面的是aspx的,后面的又是html的肯定不行了,用Redirect 吧……
2008-06-10 19:34
快速回复:为什么我的程序整天报执行子请求时出错
数据加载中...
 
   



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

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