Chandra Eskay
Chandra Eskay

Reputation: 2203

Only one asp.net page through out

I have created a web page but i want to restrict only one instance of the page should be running at all times. The scenarios are given as below.

  1. First time - User launches the page by URL and page loads.
  2. User types URL again in another window and it should say that a page is already open OR refresh the existing page.
  3. User closes the window and tries again - new fresh page will be loaded.

Additional Details : I have a database, user authentication.

Tried So Far : Set a flag in DB-->> This method how do i redirect the user back to the page which is already opened.

Any ideas to implement this.?

Thanks in Advance for your opinions and suggestions.

Upvotes: 1

Views: 186

Answers (2)

Digbyswift
Digbyswift

Reputation: 10400

You should consider using cookies for this. Create a session-long cookie upon opening of the window and destroy it upon closing of the window. If a cookie already exists, you know the window is already open.

This of course relies on javascript and is easily got round. You can not use a server-side solution because it would be impossible to catch the closing of the browser window in order to clear the cookie.

Personally, I wouldn't try and restrict the opening of multiple windows but restrict the functionality available in each window. This approach would be much easier to control using a server-side approach, e.g. events fired in the window can be validated server-side.

Upvotes: 1

Valamas
Valamas

Reputation: 24729

Perhaps you should use a cookie which expires when the user closes the browser. However, all browser instances may need to be closed.

  1. First time, there is no cookie and http_referer does not contain the same domain. (set cookie now)
  2. http_referer contains the same domain
  3. cookie expires and go back to (1)

Upvotes: 1

Related Questions