When main page is refreshed (with F5) inner iframe location is missing - iframe

I set a src attribute of an iframe as a home page, so after login we redirect the user to the home page.
When the user navigates around it is fine, but the problem comes when the user uses the F5 key on the keyboard as a refresh button.
It refreshes the entire page, which kicks them back to the main page (home page which was set as the src in iframe).
So, I have put the last visited page url in a session variable. But a problem occurs when the last visited page url uses the post method. Then just putting the url in the iframe src does not work as the form has method=post.

this is a common post problem, not related to iframe actually. this is the method i use to prevent this issue:
use posted data (store it to database etc.) and immediately redirect to another page before showing anything on screen. if some data needs to be used on the next page, read it from stored place or use either session or get method to pass to the next page.
that way, you won't have any problems with refreshing the page. you can also store the next page's url to the session variable at the posted page.

Related

Google tag manager single page application window load and history change

I'm trying to create page view tags. I have to create two for two different triggers.
Page view triggered by history change;
Page view triggered on window load (because first page load doesn't have any history change)
My problem is the home page, which is firing both tags.
Because if put in URL www.mysite.com, the page redirects to my.site.com/home
which creates a window load and a history change. So two page view tags are fired.
I can't exclude historychange trigger to exclude page path: /home because once people got into the site they'll navigate back and forth.
I can't exclude windowload because people may use either URL to enter the site (mysite.com or mystie.com/home)
Anyone can help me with this?
I suggest to create 1 page view tag instead of 2 and use both triggers. Multiple triggers in GTM tag work with OR operator. And set tag to fire once per page.
Advanced settings -> Tag firing options -> Once per page
UPD I'm afraid that in this case other hits for virtual pages triggered by History change will not be fired (because of 1 per page rule). Try to check what value have variable Old History Change after redirection. If undefined or empty, you can use it in trigger of History Change tag as exclusion.

How to preserve generated content after back button pressed?

There is some generated contents with the links on an ASP.NET page, which is created after the user inputs values and hits a button. The links take the user to another page.
When the user hits the Back button, the generated content is gone as the page returns to its initial state with the inputs cleared and generated content not there.
Is it possible to preserve the state of the page after its content has been generated and restore it after the Back button was clicked?
I think you can you can you temporary cookies.
and on load check whether cookie is exists or not.
Save the inputs in the session, so that the page will know how to correctly render on later requests. Even better, have the first code that runs when the data is submitted redirect to new page with a URL parameter that you use to know which links to show. This is a called a POST-REDIRECT-GET pattern.

ASP.NET page caching and session variable

I have a asp.net webpage that displays a link Login or Logout depending on a session variable "IsLogged". I want to implement caching in that page. But after applying caching the Login/Logout becomes inconsistent with the session variable. What is the best approach to address this problem so that I can also apply caching in that page?
Thanks,
Partha
I am not sure how you are caching specifically but you could break your page up into two user controls (ascx).
Your aspx page could contain the user control to that shows the login information (make sure that when you load the user control with a dynamic url so that the caching ignores it because the address is diff everytime like:
yourSessionInfo.ascx?stopcache=32487239875 (the number could be just current time in ticks)
You just need something that changes in your url so that the page 'looks' like it is different and reloads.
Then have the rest of your page in another user control that has a static url:
yourRestOfPage.asx
Notice nothing changing in the url so page can be cached.
Not sure if this will solve your exact problem but it should at least start you down the right path.

Getting Lightbox to Appear over Referring Page

I am working in ASP.NET (framework 2.0) with Master Pages.
I have a page that requires registration and then the user gets kicked back to the referring page.
I need to figure out how to provide a success lightbox that appears over the referring page, not the registration page (the event is fired on form submit).
I have the inline stuff in the master page and the scripts and everything fires just fine but the form is refreshed with the new (referring) page and the DIV gets hidden again.
Is sessions the only way to go here? Is there a way of having one lightbox appearing from the master page regardless of what the sub-pages are doing?
Thanks.
There should be a successful registration event. Can you emit some javascript in that scenario that would cause a redirection to the referring page. You could pass a parameter which would indicate that a light box should show up. I don't think you can redirect directly from successful registration because I am guessing that some cookie would need to be set- which the framework should handle. I might be off, but that is where I would start. I would try and avoid Session if possible.

Read page from cache on Back but not when clicking a link to the page

I have a set of interlinked dynamic web pages.
When the user clicks from one page to another, I don't want any caching to happen - the request must go to the server, which will return an up-to-date page.
But when user clicks Back, I do want the cache to be used - some of the pages can take some time to generate, which is fine when you're clicking through to them, but not when you're clicking Back.
Is this possible?
(Please don't suggest re-engineering everything as a single page making AJAX queries!)
(Note: this question is the opposite of the ever-popular "How do I prevent caching when the user clicks Back?" question.)
A common trick for avoiding the browser cache when dealing with dynamic pages is to add a parameter to the link url that is unique (using the time, to the millisecond is common).
When the user hits the 'back' button, they will go back to the last rendered version, and should get it from the cache.

Resources