trouble with caching or caching the trouble

Discussion in 'ASP .Net' started by Hypo, Jul 31, 2003.

  1. Hypo

    Hypo Guest

    Im relatilvly new to a web programming in general, and
    here's the situation i have:

    I have a default page with dynamic content, and one
    button with onclick code something like this:
    {
    // do some processing...

    Serever.Transfer("second_page.aspx");
    // or Response.Redirect("second_page.aspx"); same in
    // this case
    }

    On second page i have a new button called "return to
    default page" and in his onclick eventhandler

    if i say:
    - Serever.Transfer("second_page.aspx"); : It return
    se me to default page alright, but in the default page
    initial state, not the state in which it was just before
    user navigate to the second page.
    - Response.Redirect("second_page.aspx"); : Same thing
    like Server.Transfer(), it transfers me to the default
    page initial state.
    - Response.Write("<script>history.go(" +
    DepthIndex ");</script>"); : It transfers me to a desired
    page alright, but instantly returns where it was (on
    second page). Is this wired or what?

    I suspect problem is in caching, since it is not good
    practice to transfer or redirect to default page and
    recreate its prevous state, but i cant figure out this
    asp.net caching. I have line in my default.aspx page:
    <%@ OutputCache Duration="3600" VaryByParam="none" %>
    It results is that default page is unable to do any
    roundtrips anymore and totaly blocked. If i say:
    <%@ OutputCache Duration="3600" VaryByParam="*" %>
    It acts like there's no caching, like in firts case.
    Im aware that i must save my whole page to a cache just
    before i redirect to another page and then, when user
    wants to go back to default page, retrive it from cache
    and display it ot the user. But, how do i do that?
    Cache.Insert("DefaultPage", Self);
    and then later:
    Self = Cache["DefaultPage"];
    Or is this another of my sily ideas?

    I hope someone understud what i want, and by the way,
    viewstate is turned off globaly if it is relevant.


    Any help would be much appreciated.


    Cheers,
    Hypo - Vedran
    Hypo, Jul 31, 2003
    #1
    1. Advertising

  2. Hypo

    Hypo Guest

    i noticed some errors in my first post, heres the corect
    text:

    >-----Original Message-----

    Im relatilvly new to a web programming in general, and
    here's the situation i have:

    I have a default page with dynamic content, and one
    button with onclick code something like this:
    {
    // do some processing...

    Serever.Transfer("second_page.aspx");
    // or Response.Redirect("second_page.aspx"); same in
    // this case
    }

    On second page i have a new button called "return to
    default page" and in his onclick eventhandler

    if i say:
    - Serever.Transfer("second_page.aspx"); : It return
    se me to default page alright, but in the default page
    initial state, not the state in which it was just before
    user navigate to the second page.
    - Response.Redirect("second_page.aspx"); : Same thing
    like Server.Transfer(), it transfers me to the default
    page initial state.
    - Response.Write(""); : It transfers me to a desired
    page alright, but instantly returns where it was (on
    second page). Is this wired or what?

    I suspect problem is in caching, since it is not good
    practice to transfer or redirect to default page and
    recreate its prevous state, but i cant figure out this
    asp.net caching. I have line in my default.aspx page:
    <%@ OutputCache Duration="3600" VaryByParam="none" %>
    It results is that default page is unable to do any
    roundtrips anymore and totaly blocked. If i say:
    <%@ OutputCache Duration="3600" VaryByParam="*" %>
    It acts like there's no caching, like in firts case.
    Im aware that i must save my whole page to a cache just
    before i redirect to another page and then, when user
    wants to go back to default page, retrive it from cache
    and display it ot the user. But, how do i do that?
    Cache.Insert("DefaultPage", Self);
    and then later:
    Self = Cache["DefaultPage"];
    Or is this another of my sily ideas?

    I hope someone understud what i want, and by the way,
    viewstate is turned off globaly if it is relevant.


    Any help would be much appreciated.


    Cheers,
    Hypo - Vedran
    ..
    Hypo, Jul 31, 2003
    #2
    1. Advertising

  3. Hypo

    Hypo Guest


    >-----Original Message-----
    >The third option:
    >
    > Response.Write("<script>history.go(" +
    >DepthIndex ");</script>");


    This is third option:
    <!--
    Response.Write("<script>history.go(" + DepthIndex
    + ");</script>");
    -->
    I dont know why, but this was recognized as actual
    JScript statment inside the original post...

    >
    >sends the client back to the page where you just

    performed the
    >server.transfer or response.redirect, so this directive

    is just being sent
    >back the client again. Maybe try going back two steps

    in history.

    It doesnt matter how many steps i go back in history,
    result is always the same :(
    I, againg suspet that something with caching options is
    just not right, but i dont know what.

    >You're going to need to do a little more work if you

    want the state to be
    >saved when the client returns to the page. HTTP is

    stateless, so webpages
    >will not work this way by default. Cacheing is also not

    the solution to
    >your problem. You may want to store the contents of

    each element in the
    >page in the context object, and use server.transfer to

    move between to the
    >two pages. When you get back to the first page, you can

    use the information
    >stored in context to re-populate each element on the

    page.
    >
    >-Mark


    Recreatin of the page is not good practice, it is much
    better to save whole page (in cache?) nad retrive it
    later. Anyway, it says that in msdn, but it dont show
    how...
    Hypo, Jul 31, 2003
    #3
  4. Hypo

    Hypo Guest

    ???

    Damn, this post engine dosnt show any html elements
    inside the post, sory folks...... hello ms, gotta a new
    bug ?
    Hypo, Jul 31, 2003
    #4
  5. Since you have done nothing to grab the ViewState going to the second page,
    the values are cleared out for both Response.Redirect and Server.Transfer.
    In the case of the JavaScript, check the condition that causes the page to
    transfer. Most likely, you are sending them back to the page, but the
    condition forwarding them is still true (not surprising actually, as the
    value is likely stored, along with everything else, in viewstate).


    Without understanding your application, I cannot comment specifics, but it
    is likely you are going about this the wrong way ... from a .NET
    perspective. You have options:

    1. Grab the ViewState info on the second_page.aspx page and store it for
    when a person hits the "go back" condition. You can then reconstitute the
    form.

    2. Build up forms with multiple views (using, for example, panels). As a
    person steps through you show different panels. You can then save the
    information for all panels as they are filled out, and go back to any step
    without losing the data from other steps. This may be what you are aiming
    at.

    3. Go to a multi-tiered setup where individual pages make up the views. The
    Microsoft UI Process Application Block can be used, if you want a true OO
    solution.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA
    Author: ADO.NET and XML: ASP.NET on the Edge

    ****************************************************************************
    ****
    Think Outside the Box!
    ****************************************************************************
    ****
    "Hypo" <> wrote in message
    news:0b6901c35764$86de0830$...
    > Im relatilvly new to a web programming in general, and
    > here's the situation i have:
    >
    > I have a default page with dynamic content, and one
    > button with onclick code something like this:
    > {
    > // do some processing...
    >
    > Serever.Transfer("second_page.aspx");
    > // or Response.Redirect("second_page.aspx"); same in
    > // this case
    > }
    >
    > On second page i have a new button called "return to
    > default page" and in his onclick eventhandler
    >
    > if i say:
    > - Serever.Transfer("second_page.aspx"); : It return
    > se me to default page alright, but in the default page
    > initial state, not the state in which it was just before
    > user navigate to the second page.
    > - Response.Redirect("second_page.aspx"); : Same thing
    > like Server.Transfer(), it transfers me to the default
    > page initial state.
    > - Response.Write("<script>history.go(" +
    > DepthIndex ");</script>"); : It transfers me to a desired
    > page alright, but instantly returns where it was (on
    > second page). Is this wired or what?
    >
    > I suspect problem is in caching, since it is not good
    > practice to transfer or redirect to default page and
    > recreate its prevous state, but i cant figure out this
    > asp.net caching. I have line in my default.aspx page:
    > <%@ OutputCache Duration="3600" VaryByParam="none" %>
    > It results is that default page is unable to do any
    > roundtrips anymore and totaly blocked. If i say:
    > <%@ OutputCache Duration="3600" VaryByParam="*" %>
    > It acts like there's no caching, like in firts case.
    > Im aware that i must save my whole page to a cache just
    > before i redirect to another page and then, when user
    > wants to go back to default page, retrive it from cache
    > and display it ot the user. But, how do i do that?
    > Cache.Insert("DefaultPage", Self);
    > and then later:
    > Self = Cache["DefaultPage"];
    > Or is this another of my sily ideas?
    >
    > I hope someone understud what i want, and by the way,
    > viewstate is turned off globaly if it is relevant.
    >
    >
    > Any help would be much appreciated.
    >
    >
    > Cheers,
    > Hypo - Vedran
    Cowboy \(Gregory A. Beamer\), Jul 31, 2003
    #5
  6. ViewState will still be holding the condition that causes the original
    Server.Transfer(), so JavaScript back is not a great option when you are
    transfering.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA
    Author: ADO.NET and XML: ASP.NET on the Edge

    ****************************************************************************
    ****
    Think Outside the Box!
    ****************************************************************************
    ****
    "Mark Heimonen" <> wrote in message
    news:%...
    > The third option:
    >
    > Response.Write("<script>history.go(" +
    > DepthIndex ");</script>");
    >
    > sends the client back to the page where you just performed the
    > server.transfer or response.redirect, so this directive is just being sent
    > back the client again. Maybe try going back two steps in history.
    >
    > You're going to need to do a little more work if you want the state to be
    > saved when the client returns to the page. HTTP is stateless, so webpages
    > will not work this way by default. Cacheing is also not the solution to
    > your problem. You may want to store the contents of each element in the
    > page in the context object, and use server.transfer to move between to the
    > two pages. When you get back to the first page, you can use the

    information
    > stored in context to re-populate each element on the page.
    >
    > -Mark
    >
    >
    > "Hypo" <> wrote in message
    > news:0b6901c35764$86de0830$...
    > > Im relatilvly new to a web programming in general, and
    > > here's the situation i have:
    > >
    > > I have a default page with dynamic content, and one
    > > button with onclick code something like this:
    > > {
    > > // do some processing...
    > >
    > > Serever.Transfer("second_page.aspx");
    > > // or Response.Redirect("second_page.aspx"); same in
    > > // this case
    > > }
    > >
    > > On second page i have a new button called "return to
    > > default page" and in his onclick eventhandler
    > >
    > > if i say:
    > > - Serever.Transfer("second_page.aspx"); : It return
    > > se me to default page alright, but in the default page
    > > initial state, not the state in which it was just before
    > > user navigate to the second page.
    > > - Response.Redirect("second_page.aspx"); : Same thing
    > > like Server.Transfer(), it transfers me to the default
    > > page initial state.
    > > - Response.Write("<script>history.go(" +
    > > DepthIndex ");</script>"); : It transfers me to a desired
    > > page alright, but instantly returns where it was (on
    > > second page). Is this wired or what?
    > >
    > > I suspect problem is in caching, since it is not good
    > > practice to transfer or redirect to default page and
    > > recreate its prevous state, but i cant figure out this
    > > asp.net caching. I have line in my default.aspx page:
    > > <%@ OutputCache Duration="3600" VaryByParam="none" %>
    > > It results is that default page is unable to do any
    > > roundtrips anymore and totaly blocked. If i say:
    > > <%@ OutputCache Duration="3600" VaryByParam="*" %>
    > > It acts like there's no caching, like in firts case.
    > > Im aware that i must save my whole page to a cache just
    > > before i redirect to another page and then, when user
    > > wants to go back to default page, retrive it from cache
    > > and display it ot the user. But, how do i do that?
    > > Cache.Insert("DefaultPage", Self);
    > > and then later:
    > > Self = Cache["DefaultPage"];
    > > Or is this another of my sily ideas?
    > >
    > > I hope someone understud what i want, and by the way,
    > > viewstate is turned off globaly if it is relevant.
    > >
    > >
    > > Any help would be much appreciated.
    > >
    > >
    > > Cheers,
    > > Hypo - Vedran

    >
    >
    Cowboy \(Gregory A. Beamer\), Jul 31, 2003
    #6
  7. Hypo

    Hypo Guest

    To bring you little closly my app. :

    default.aspx and second_page.aspx consists form datagrids
    with custom paging implemented, and navigation buttons.
    Viewstate is turned off glabaly for all elements (is this
    good?)

    Hypothethical situation. User browse on default's page
    datagird and lets say go to page 5. Then he hits the
    button to transfer himself on second_page.aspx. Do what
    he have to to on second_page then he wants to go back on
    default to continue browsing, he hits the >> back <<
    button on page Response.Redirect("default.apsx") do his
    job, he is back on defalt page but not any more on pga 5,
    but page 1 (initial page).

    How do i avoid this situation, yes i can recreate page
    using session variable, but i dont want. It mus be some
    better solution.

    Thanks for your time, best regards
    Vedran
    Hypo, Aug 1, 2003
    #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. Dmitry Bond.
    Replies:
    2
    Views:
    616
    Dmitry Bond.
    Aug 24, 2005
  2. RMD

    Caching Design Issue

    RMD, Jun 24, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    987
    mai86
    Oct 8, 2008
  3. Teo Lachev
    Replies:
    0
    Views:
    394
    Teo Lachev
    Jul 1, 2003
  4. Troy Simpson

    Fragment Caching inside page caching?

    Troy Simpson, Jan 19, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    783
    Troy Simpson
    Jan 19, 2004
  5. JimLad
    Replies:
    3
    Views:
    911
    JimLad
    Jan 21, 2010
Loading...

Share This Page