Friday, 21 December 2007

.NET AJAX .axd give error regarding utcDate

Both WebResource.axd and ScriptResource.axd give an error at System.Web.HttpCachePolicy.UtcSetLastModified(DateTime utcDate) method, as shown below:

[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

Parameter name: utcDate]

System.Web.HttpCachePolicy.UtcSetLastModified(DateTime utcDate) +3258643
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

First, look for the simple. If it's your machine's date time is in the past (or the future), then it is easy to fix. Just change your system clock.

In our case, it is not that straight forward. We have moved the time forward for a while, and ASP .NET 2.0 SP1 was installed while the time is in the future. So basically the assemblies and GAC modified date time is in the future. AJAX does not like it. I guess it is a bug.

We wanted to uninstall and reinstall SP1, but windows does not allow us to remove it. So we click "change" instead of "remove" in Add/Remove programs. Not sure what did windows do, but magically it works. It probably update all the installed dlls, so the modified date times are corrected.

Otherwise, we may have to "touch" all the files... :(

19 comments:

  1. This solution is working in our case. We tried to resolve this issue for last 2 days and finally got the solution. Thank you very much !!

    ReplyDelete
  2. Worked a treat, thank you very much!!

    ReplyDelete
  3. Thank you for the tips, you saved me a lot of time.

    ReplyDelete
  4. I pay my respects to you, great article

    ReplyDelete
  5. Immensely useful! This just saved me loads of time and frustration trying to work out why we were getting JS errors all over our app during some testing that required changing the server time... thank you so much :D

    ReplyDelete
  6. Feeling very happy , had wasted so much of time on this .....Was juggling around with mapping of Webresource file with WebDevelopment server issues for improper rendering of tree control.
    Thanks a ton !

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. This also worked for me except I had to do a repair on .NET 3.5 SP1 instead. Thanks!

    ReplyDelete
  9. Thank you,
    It works for us. Thanx a lot

    ReplyDelete
  10. Hey Gypsy... thanks much for the article... turns out we had the same problem!
    -sri

    ReplyDelete
  11. I had this same problem earlier... but forgot how I fixed it. Now I came across your blog. Helped a lot! Awesome!

    ReplyDelete
  12. i changed the system date, the error disappeared !

    ReplyDelete
  13. Nice. You have saved me a lot of time. =)

    ReplyDelete
  14. Thank you so much! :) This solved my problem.

    ReplyDelete
  15. Hii
    this blog is really helpful to me

    ReplyDelete
  16. There's one more approach that worked for me.

    try running: for %i in (*.dll) do copy /b %i+,,
    in the Bin directory of the application

    it means that the assembly was built in future according to the webserver, the command above will 'touch' them so they appear to be of current date

    http://stackoverflow.com/questions/2782329/specified-argument-was-out-of-the-range-of-valid-values-parameter-name-utcdate

    ReplyDelete