Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6177895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:21:24+00:00 2026-05-24T00:21:24+00:00

Trying to set cache response headers on a dynamically-generated image, I’m getting a weird

  • 0

Trying to set cache response headers on a dynamically-generated image, I’m getting a weird error:

ArgumentOutOfRangeException was unhandled by user code

Specified argument was out of the range of valid values.

Parameter name: utcDate

I’m reading the file’s last write time from a data cache, and then calling

Response.Cache.SetLastModified(lastWriteTime.Value.ToUniversalTime());

The last write time’s value is {2011-07-25 18:09:56}, as I’d expect… I have no idea why this is going wrong.

The MSDN documentation for this method contains the rather cryptic statement (my emphasis):

The Last-Modified HTTP header time stamps the document with the DateTime value indicating when the document was last modified.

This method will fail if the caching restrictiveness hierarchy is violated.

SetLastModified is introduced in the .NET Framework version 3.5. For more information, see .NET Framework Versions and Dependencies.

What is a caching restrictiveness hierarchy? Am I violating one? If not, why is the last modified time being rejected?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:21:24+00:00Added an answer on May 24, 2026 at 12:21 am

    SetLastModified will throw ArgumentOutOfRangeException if your lastWriteTime is in the future.

    This will succeed:

    var t1 = DateTime.Now;
    Response.Cache.SetLastModified(t1);
    

    This will fail:

    var t2 = DateTime.Now + new TimeSpan(0, 0, 0, 1);
    Response.Cache.SetLastModified(t2);
    

    Decompiling System.Web illustrates this:

    public void SetLastModified(DateTime date)
    {
      this.UtcSetLastModified(DateTimeUtil.ConvertToUniversalTime(date));
    }
    
    private void UtcSetLastModified(DateTime utcDate)
    {
      utcDate = new DateTime(utcDate.Ticks - utcDate.Ticks % 10000000L);
      if (utcDate > DateTime.UtcNow)
        throw new ArgumentOutOfRangeException("utcDate");
      if (this._isLastModifiedSet && !(utcDate > this._utcLastModified))
        return;
      this.Dirtied();
      this._utcLastModified = utcDate;
      this._isLastModifiedSet = true;
    }
    

    Are you generating the lastWriteTime on one server and then reading on another where there is a time discrepancy between the servers?

    Some additional points:

    • You can also see that you don’t need ToUniversalTime as the framework does that for you
    • Looks like the first line in UtcSetLastModified reduces precision
    • I can’t tell you want a “caching restrictiveness hierarchy” is!
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to set up a session and i am getting a header error,
When trying to set DoMatchParen I get the following error: E492: Not an editor
I'm trying to cache user controls and on some pages i want to cache
Im trying to set up some cache control options in my htaccess file. At
I'm trying to set up a server-side cache properly and I'm looking for constructive
I'm trying to manually set an object in the Django cache API but it
I was trying to set up cache for my Django application but it seems
I'm trying to get ASP.Net to cache the response of a web service request
We are trying to set up appfabric cache on a cluster with 6 machines.
I'm trying to set up a cache manifest for a site and am having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.