Refresh Page

Discussion in 'ASP .Net' started by David, Jan 3, 2005.

  1. David

    David Guest

    Hello.

    I have such problem:
    I have ImageButton on my form which is attached to some image like
    "image.jpg", now when I change image file (physically file) with some other
    file with the same name my page shows the old image until I click "Refresh"
    button of the browser.
    So how can I refresh web form from code?
    Or may be there is some other way to solve this problem?

    Thank you.
    David, Jan 3, 2005
    #1
    1. Advertising

  2. David

    David Guest

    No! It's imposable.
    Is there any other way?

    "Eliyahu Goldin" <> wrote in message
    news:e2DB6%...
    > The image gets cached on client side. You can trick the browser onto
    > refreshing the image by adding a random number to the image url. For
    > example
    > image.jpg?1234
    >
    > Eliyahu
    >
    > "David" <> wrote in message
    > news:%...
    >> Hello.
    >>
    >> I have such problem:
    >> I have ImageButton on my form which is attached to some image like
    >> "image.jpg", now when I change image file (physically file) with some

    > other
    >> file with the same name my page shows the old image until I click

    > "Refresh"
    >> button of the browser.
    >> So how can I refresh web form from code?
    >> Or may be there is some other way to solve this problem?
    >>
    >> Thank you.
    >>
    >>

    >
    >
    David, Jan 3, 2005
    #2
    1. Advertising

  3. The image gets cached on client side. You can trick the browser onto
    refreshing the image by adding a random number to the image url. For example
    image.jpg?1234

    Eliyahu

    "David" <> wrote in message
    news:%...
    > Hello.
    >
    > I have such problem:
    > I have ImageButton on my form which is attached to some image like
    > "image.jpg", now when I change image file (physically file) with some

    other
    > file with the same name my page shows the old image until I click

    "Refresh"
    > button of the browser.
    > So how can I refresh web form from code?
    > Or may be there is some other way to solve this problem?
    >
    > Thank you.
    >
    >
    Eliyahu Goldin, Jan 3, 2005
    #3
  4. Yes, in the code-behind:

    Response.ExpiresAbsolute = DateTime.Now.AddDays (-1);
    Response.Cache.SetCacheability (System.Web.HttpCacheability.NoCache);

    Response.AppendHeader ("Pragma", "no-cache");


    Eliyahu

    "David" <> wrote in message
    news:...
    > No! It's imposable.
    > Is there any other way?
    >
    > "Eliyahu Goldin" <> wrote in message
    > news:e2DB6%...
    > > The image gets cached on client side. You can trick the browser onto
    > > refreshing the image by adding a random number to the image url. For
    > > example
    > > image.jpg?1234
    > >
    > > Eliyahu
    > >
    > > "David" <> wrote in message
    > > news:%...
    > >> Hello.
    > >>
    > >> I have such problem:
    > >> I have ImageButton on my form which is attached to some image like
    > >> "image.jpg", now when I change image file (physically file) with some

    > > other
    > >> file with the same name my page shows the old image until I click

    > > "Refresh"
    > >> button of the browser.
    > >> So how can I refresh web form from code?
    > >> Or may be there is some other way to solve this problem?
    > >>
    > >> Thank you.
    > >>
    > >>

    > >
    > >

    >
    >
    Eliyahu Goldin, Jan 3, 2005
    #4
  5. David

    Joerg Jooss Guest

    Eliyahu Goldin wrote:
    > Yes, in the code-behind:
    >
    > Response.ExpiresAbsolute = DateTime.Now.AddDays (-1);
    > Response.Cache.SetCacheability (System.Web.HttpCacheability.NoCache);
    >
    > Response.AppendHeader ("Pragma", "no-cache");


    This only affects the page itself, but not any referenced resource. In order
    to make the image file non-cacheable, put all it and all other non-cacheable
    images in a common folder and assign this folder the HTTP headers

    Cache-Control: no-cache (*)
    Pragma: no-cache

    using the IIS admin applet.

    (*) Technically, "Cache-Control: must-revalidate" would be the right choice,
    but IE handles this incorrectly :-(


    Cheers,
    --
    Joerg Jooss
    www.joergjooss.de
    Joerg Jooss, Jan 3, 2005
    #5
  6. That is the way it should be done. I read a great article about what
    yahoo.com does for their impression ads and image tracking. You will need
    to put some value on the end of the src.

    <img srg="http:\\site.com\images\bob.jpg?5531234">

    This will force the client browser to "redownload" the image, as it doesn't
    think it has it downloaded already.

    bill

    "David" <> wrote in message
    news:...
    > No! It's imposable.
    > Is there any other way?
    >
    > "Eliyahu Goldin" <> wrote in message
    > news:e2DB6%...
    > > The image gets cached on client side. You can trick the browser onto
    > > refreshing the image by adding a random number to the image url. For
    > > example
    > > image.jpg?1234
    > >
    > > Eliyahu
    > >
    > > "David" <> wrote in message
    > > news:%...
    > >> Hello.
    > >>
    > >> I have such problem:
    > >> I have ImageButton on my form which is attached to some image like
    > >> "image.jpg", now when I change image file (physically file) with some

    > > other
    > >> file with the same name my page shows the old image until I click

    > > "Refresh"
    > >> button of the browser.
    > >> So how can I refresh web form from code?
    > >> Or may be there is some other way to solve this problem?
    > >>
    > >> Thank you.
    > >>
    > >>

    > >
    > >

    >
    >
    William F. Robertson, Jr., Jan 3, 2005
    #6
  7. David

    Joerg Jooss Guest

    William F. Robertson, Jr. wrote:
    > That is the way it should be done.


    Should? No, not really. HTTP 1.1 covers all required cache and expiration
    mechanisms. But if you said "must" be done, you're most likely correct.
    There are still too many crappy HTTP implementations out there that are
    beyond any poor web application developer's control :-(

    Cheers,
    --
    Joerg Jooss
    www.joergjooss.de
    Joerg Jooss, Jan 3, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. brian lanning
    Replies:
    0
    Views:
    592
    brian lanning
    Jul 29, 2003
  2. Lenny Shprekher
    Replies:
    0
    Views:
    2,329
    Lenny Shprekher
    Feb 23, 2005
  3. Per Magnus L?vold
    Replies:
    1
    Views:
    5,117
    John C. Bollinger
    Oct 8, 2004
  4. Pkenty
    Replies:
    0
    Views:
    389
    Pkenty
    May 28, 2004
  5. Jawahar Rajan
    Replies:
    1
    Views:
    290
    Adrienne
    Oct 1, 2003
Loading...

Share This Page