trouble with caching or caching the trouble

H

Hypo

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
 
H

Hypo

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
..
 
H

Hypo

-----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...
 
H

Hypo

Damn, this post engine dosnt show any html elements
inside the post, sory folks...... hello ms, gotta a new
bug ?
 
C

Cowboy \(Gregory A. Beamer\)

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.


Hypo said:
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
 
C

Cowboy \(Gregory A. Beamer\)

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.


Mark Heimonen said:
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 said:
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
 
H

Hypo

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top