Here is something I didn't know until recently:
If you have a ScriptControl whose JavaScript files are web resources (served through ScriptResource.axd instead of WebResource.axd) and the date of the assembly is in the future, that very JavaScript file will fail to load.
I have attached a test solution to illustrate the case -
AssemblyInTheFuture.zip. Build it and run the Default.aspx page - everything is fine and a nasty alert saying "initialize" pops out. Now change the date of your PC - set it to yesterday. Stop ASP.NET Development server to reset the script resource cache dependency. Open Default.aspx again (but DO NOT rebuild the project - let the ControlLibrary.dll be built in the future). Now a JavaScript error will occur saying that 'aStuff is undefined' or 'aStuff is not defined' if you are a FireFox guy (like yours truly). Firebug can immediately tell you why:
Here is the error in more user friendly format:
Specified argument was out of the range of valid values.
Parameter
name: utcDate
Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code.
Exception Details:
System.ArgumentOutOfRangeException: Specified argument was out of the range
of valid values.
Parameter name: utcDate
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below. |
Stack Trace:
[ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: utcDate] System.Web.HttpCachePolicy.UtcSetLastModified(DateTime utcDate) +3261043 System.Web.HttpCachePolicy.SetLastModified(DateTime date) +47 System.Web.Handlers.ScriptResourceHandler.PrepareResponseCache(HttpResponse response, Assembly assembly) +194 System.Web.Handlers.ScriptResourceHandler.ProcessRequest(HttpContext context) +1154 System.Web.Handlers.ScriptResourceHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context) +4 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64 |
Version Information: Microsoft .NET Framework Version:2.0.50727.42;
ASP.NET Version:2.0.50727.213
A good thing to know is that the good old WebResource.axd does not depend on the time. You can try the following (in Default.aspx.cs):
protected void Page_Load(object sender, EventArgs e)
{
Page.ClientScript.RegisterClientScriptResource(typeof(AjaxWebControl), "aStuff.AjaxWebControl.js");
}
If you load the page a new JavaScript error will occur - "Type is undefined" which means that the file has been served successfully but is included before the core ASP.NET AJAX scripts.
In a word always make sure that you don't deploy assemblies which are built in the future :) This may happen if you deploy your web site on a server in a different time zone.
And don't forget to restore your system date :)