立即RewritePath到刚生成一个html会产生错误

以下是错误信息:
==================

指定的参数已超出有效值的范围。参数名: date

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.ArgumentOutOfRangeException: 指定的参数已超出有效值的范围。参数名: date

源错误:

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。

堆栈跟踪:

[ArgumentOutOfRangeException: 指定的参数已超出有效值的范围。
            参数名: date]
            System.Web.HttpCachePolicy.UtcSetLastModified(DateTime utcDate)
            System.Web.HttpCachePolicy.SetLastModified(DateTime date)
            System.Web.StaticFileHandler.ProcessRequest(HttpContext context)
            System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
            System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
            


版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573

=======================================
以下是方法代码
private void context_BeginRequest(object sender, EventArgs e)
{
    HttpApplication application 
= (HttpApplication)sender;
    HttpContext context 
= application.Context;

    
string strUrl = context.Request.RawUrl;//读取请求的Url
    string str = SimpleHtmlModule.GetHtmlPage(strUrl);//获取对应的html文件名
    if(str == "")//没有对应的html
    {
        context.RewritePath(strUrl);
        
return;
    }


    
string strFile = context.Server.MapPath(str);//获取html的绝对路径           

    
if(System.IO.File.Exists(strFile))//检查html文件是否存在
    {
        context.RewritePath(str);
//跳转到html
    }

    
else
    
{
        
if(BuildHtmlPage(strUrl,strFile))//尝试生成html文件
        {
            context.RewritePath(str);
//生成成功跳转到html   
        
//    context.RewritePath(strUrl);//生成成功跳转到原aspx面页  
        }

        
else
        
{
            context.RewritePath(
"msg.aspx");
            context.Response.Write(
"你访问的页面" + strUrl + "不存在");    
        }

    }

}

问题很奇怪,生成html生立即RewritePath会出错,如果改为生成后RewirtePath到原aspx文件就不会出错。更奇怪的是如果放一个断点一步步的运行,错误就不存在!我的是XP系统。代码在win2003下测试是通过的。

posted @ 2006-04-01 16:40  生命体验之kevin-Y  阅读(750)  评论(0编辑  收藏  举报