Immediately rewritepath to just generate an HTML will generate an error

Source: Internet
Author: User
The following error message is displayed:
============================
The specified parameter has exceeded the valid value range. Parameter Name: Date

Note:An error occurred while executing the current Web request. Check the stack trace information for details about the error and the source of the error in the code.

Exception details:System. argumentoutofrangeexception: the specified parameter has exceeded the valid value range. Parameter Name: Date

Source error:

An unhandled exception is generated during the execution of the current Web request. You can use the following exception stack trace information to determine the cause and location of the exception.

Stack trace:

[Argumentoutofrangeexception: the specified parameter has exceeded the valid value range. Parameter Name: 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)

Version:Microsoft. NET Framework Version: 1.1.4322.573; ASP. NET version: 1.1.4322.573

========================================================
The method code is as follows:

Private void context_beginrequest (Object sender, eventargs E)
{
Httpapplication application = (httpapplication) sender;
Httpcontext context = application. context;

String strurl = context. Request. rawurl; // read the request URL
String STR = simplehtmlmodule. gethtmlpage (strurl); // obtain the corresponding HTML file name
If (STR = "") // no corresponding html
{
Context. rewritepath (strurl );
Return;
}

String strfile = context. server. mappath (STR); // obtain the absolute path of HTML

If (system. Io. file. exists (strfile) // check whether the HTML file exists
{
Context. rewritepath (STR); // jump to HTML
}
Else
{
If (buildhtmlpage (strurl, strfile) // try to generate an HTML file
{
Context. rewritepath (STR); // jump to HTML
// Context. rewritepath (strurl); // The generated result is successfully redirected to the original ASPX page.
}
Else
{
Context. rewritepath ("MSG. aspx ");
Context. response. Write ("the page you accessed" + strurl + "does not exist ");
}
}
}

The problem is very strange. An error occurs when generate an HTML generate rewritepath immediately. If it is changed to the generated rewirtepath to the original aspx file, no error will occur. What's even more strange is that if you put a breakpoint for step-by-step running, the error will not exist! I use the XP system. The Code passed the test in win2003.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.