Capture the browser's back button in an MVC4 web application and execute a Controller's Action - asp.net-mvc-4

We have developed an MVC4 Web Application. Due to the flow of pages (it is a reservation system) we need when the user pressed back button the page to be executed again ie reload data from database as it was called from first time.
May be a solution is to suggest how to Capture the browser's back button in an MVC4 web application and execute a Controller's Action
Kindly consider.
Any assistance is kindly appreciated.

Based on your comments it seems you are building up state over several pages (in a wizard style) and it is when navigating back to an earlier page that you would like the state to be cleared.
You would need to capture the page navigation logic on the server side and not rely on capturing back button events on the client side.
You should use the state you've captured to determine what should be displayed to the user and what should happen to the current state you have.
For example, imagine you have pages A, B, C, D which collect user information. The user has entered information on pages A and B (which has been gathered in the session or the database perhaps) and is now on page C. They then navigate back to page A (via the back button or by modifying the url directly). At this point (in the controller for page A) you can determine from the current state that they have been to page B and therefore deduce that they must have navigated back. You can therefore clear the state at this point or perform whatever logic is required.

Related

Show/Hide region when button pressed in another page Oracle APEX

I have a Home Page, it shows the status of the information of the company. But some days, there is some delay of information, due to errors in the PL's or in the server. Today I created a new region in the Home Page that shows a disclaimer/text/warning that there is a delay of 5 hours(I will delete this item at the end of the day or the 5 hours of delay). But I want to know if it's possible, that this message (I created another page with a text area item) written by my coworkers, can appear with a button from the other page and then hide the original region in the Home Page.
I'm using Oracle APEX 5.1
Thanks in advance.
So your ask is: Can I control what is shown/hidden in my Home Page from another page? Sure you can! You can try using APEX's Application Settings.
Then just:
Create an application setting (e.g. SHOW_MESSAGE)
Create buttons and a process attached to it calling the SET_VALUE procedure setting SHOW_MESSAGE to Y or N
-- from the Documentation example
begin
APEX_APP_SETTING.SET_VALUE(
p_name => 'SHOW_MESSAGE',
p_value => 'Y' );
end;
On your home page, just add a Server-Side Condition to the region checking if the GET_VALUE equals to Y
Apex does not support push notifications to push messages from the server, but you can use a workaround.
Create a region on the home page that displays the message
Create a dynamic action on page load to hide the message region if the message text is null
Create an an application process return 'Y' if there is a text message to show and 'N' when there is no message. The processing point of this process should be "Ajax Callback...". There are quite a bit of examples on the web on how to use application processes in ajax callback.
On your home page, create a javascript function (in section "Function and Global Variable Declaration") that invokes the application process and shows/hides the message regions based on the result.
On your home page, execute a javascript timer function (in section "Execute when Page Loads") to check every xx milliseconds for updates.
Notes:
As you can see this is quite a bit of relatively advanced work. You might consider showing the message at page rendering time instead.
Don't set the number of milliseconds too low. For every user on this page, a request to the database will be fired every xx milliseconds which can lead to a lot of traffic. For a case like yours, I'd set that to every 2 or even 5 minutes.
This is just one implementation, there are other options (using events, dynamic actions, etc) but it all boils down to the same technique: process on client running at interval.

Branch.io custom event count not increasing for quick links

I have created a quick link from https://dashboard.branch.io/quick-links. When the user opens the link and tries to register the account on our website, a custom event is triggered from server side (Java) using the branch http API.
I can see that event in the Liveview section of Branch.io dashboard. But, when I go to the quicks section, the count for my custom event column is always showing as 0.
Is there any specific Branch related parameter that I need to send from client side (browser) to server side while submitting the form, to let Branch know that the custom event should be linked to a specific link, so I can see the custom event count increasing for that link in quick links section.
Your custom event will not be attributed to your link click if you trigger the event on the server side.
You should trigger the custom event from the client side post registration. You can put this in the callback of your registration method. If you navigate away from the initial redirect to your webpage, make sure that page has the Branch Web SDK initialized, and that you have the _branch_match_id(found in the address bar of your redirect) appended to your web url. This _branch_match_id is what Branch uses to attribute the custom event to your link click.
https://docs.branch.io/pages/web/integrate/#track-events

Managing session temporarily in ibm mobilefirst?

i have to develop a multipage application that includes invocation of several web services.
My first page has a login page. based on the user input i have to traverse to next page while calling the next web service simultaneously. so obviously this all depends on the login page information that has the userid and password and the response from the web service such as personId etc.
i need to store this information temporarily for a particular session but... how to do this?
There are two kinds of page:
There are the UI states as seen by the user. Your Login page and your Next page are examples of these. From the user's perspective they see a succession of pages.
However you are writing an App, a single controlling thing that is in charge of all those "UI pages". I suppose that you are using MobileFirst to create a hybrid application that is effectively executing in a browser. From that browser's perspective you have a single HTML page. This is important, MobileFirst only works with single-page applications.
Now the browser loads the HTML and JavaScript for your single application page and that JavaScript stays resident as the user moves between the different "UI Pages", so the JavaScript can have variables for keeping the state you are asking about. The actual UI navigation from "page" to "page" is usually done by hiding and revealing DIVs.
Hence your WebService call results will be delivered (asynchronously) to some JavaScript function you define, and in the meantime your code can hide the login page and reveal the next page as required. The login data being held in JavaScript variabes.
All of this is simplified by using a framework such as AngularJS which abstracts the messy details of hiding and revealing and dealing with asynch delivery.

Loading cached pages with different content in WindowsRT Store App

I want to enable caching for a page that loads when an ListView item is clicked. So when the user clicks a second time on the same item, the app will navigate to the previous cached page.
(I'm using LayoutAwarePages and I suspect that this should be possible if in the OnNavigatedTo method the NavigationMode parameter is different from NavigationMode.New)
Any ideas?
You affect the page caching by setting the NavigationCacheMode property of the page in its constructor. By default it is disabled, but if you enable it, you'll get the existing page instance every time you navigate to it. This means that even if the user navigates to a different item in your ListView, the same instance of the page will be reused.
I've found a library reimplementing the navigation framework to make it more like the one in Windows Phone, i.e.:
When navigating back the cached page is used.
When navigating forward a new instance of the page is created.
If I understand your question correctly, you require a different caching behavior from both of the above. To achieve that you could either base your alternative navigation framework on the one in the library I linked to or simulate the behavior by persisting just the page state for each item instead of actually caching the pages.

How to detect if user has switched Rails 3

A user logs into my application in a tab in a browser
They get an email and click a link which opens a new tab in the same browser and logs them in under a different email say.
If they go back to the first tab they are no longer the same user and I want the page to automatically detect this and then reload or redirect them if they are unauthorized to view the page.
Anyway to do this?
Or, if you really want to know when user is switched the tab, try this library:
visibility.js
As stated by #Hck:
add javascript code to reload page periodically (for example once per 30 seconds) – Hck
JavaScript is pretty much the only way to make pages do stuff after they're loaded. Note that in pretty much any user authentication system, a given browser will only be logged in as one user at a time, so as soon as the second tab opens, that browser will be acting as the second user - they can still see the current content of the first tab, but links (for instance) will no longer work unless the second user was also authorized to use them.
There are some JQuery plugins that do this sort of thing, like PeriodicalUpdater, or you can write your own (an example).