Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Pressing Back button prevents page from running

Author  Topic 

chriskhan2000
Aged Yak Warrior

544 Posts

Posted - 2005-03-02 : 18:12:10
I have an aspx page that allows the user to choose a database and enter username and password which it checks against the SQL database. Once it is authenticated, the user can run a report query. This works fine the first time, but if the user clicks the back button to select another database to run, it seems to stall for a very long time and will not run the new database.

I did close my database connection after it is opened to retrieve the information.

Anyone with any ideas on this?

MichaelP
Jedi Yak

2489 Posts

Posted - 2005-03-02 : 19:39:03
When you are running the report, are you using a data reader? If so, are you closing the reader? Is anything getting stored in cache? In Session?

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

chriskhan2000
Aged Yak Warrior

544 Posts

Posted - 2005-03-03 : 08:55:30
Yes. I'm using session and data reader. Any ideas how I can close those?
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2005-03-03 : 11:54:07
when you open a datareader, You should be able to pass in a param to close the reader when the connection is closed. I can't remember what it is, but you should be able to figure it out.

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

chriskhan2000
Aged Yak Warrior

544 Posts

Posted - 2005-03-03 : 15:30:38
I'm able to close the data reader, but any ideas how I would close a session?

dgOder.DataSource = drSales.ExecuteReader(CommandBehavior.CloseConnection)
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2005-03-03 : 15:43:04
You shouldn't need to close the session. What all are you storing in Session? Any connections, datatables, datasets, datareaders?

Michael



<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

chriskhan2000
Aged Yak Warrior

544 Posts

Posted - 2005-03-03 : 16:14:13
The only thing that is stored in the session is the database name, username, and password. I'm not sure if it's the session that is causing the problem. I do close my database and data reader after it is open.

This is what I was thinking of doing, but I can't seem to get it to work. If the user press the back button, at page load, I want to set it so that it checks to see if there's already a session. If there is, then just redirect them to the mainpage. The problem is taht when pressing the back button, it does not do a page load but from cache memory. How would I set it so that it will clear the cache when they do a back button.

Also I plan to have a logout button so that when they click the logout, it will close or reset the session and bring the user back to the login page. HOw would I reset or clear a session?

Any ideas?

Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2005-03-03 : 17:14:05
Session.Clear()

-Chad

http://www.phxpoker.com

Phoenix's largest online poker community
Go to Top of Page

chriskhan2000
Aged Yak Warrior

544 Posts

Posted - 2005-03-03 : 17:19:30
Thanks Chad. That's what I needed. So simple, yet so hard hehe.
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2005-03-03 : 18:39:13
If you clear the session each time, isn't that gonna kick the users out of your site after they hit the first page?

You probably need to disable caching of the pages in your code.
Do some searching for Disable page caching .net.

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

chriskhan2000
Aged Yak Warrior

544 Posts

Posted - 2005-03-04 : 12:53:19
Here's what I did. I added a code so that when they press the back button, it will reload the first page and check to see if there's something in session. If it is, then take them back to main page, but if it doesn't then take them to main login.

Now for the session to clear, I left that as a logout button. If they click on that, it will log them out and redirect them back to the login.

So this seems to work as intended.
Go to Top of Page

jhermiz

3564 Posts

Posted - 2005-03-08 : 00:05:25
quote:
Originally posted by chriskhan2000

Here's what I did. I added a code so that when they press the back button, it will reload the first page and check to see if there's something in session. If it is, then take them back to main page, but if it doesn't then take them to main login.

Now for the session to clear, I left that as a logout button. If they click on that, it will log them out and redirect them back to the login.

So this seems to work as intended.



Also might want to check out the global.asax file. You will need to clear the session when the application is completly gone you may also make some global wide settings to the application here as well.




Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]
Imperfection living for perfection --
[url]http://jhermiz.blogspot.com/[/url]
Go to Top of Page

chriskhan2000
Aged Yak Warrior

544 Posts

Posted - 2005-03-08 : 09:53:27
Thanks I will look into that.
Go to Top of Page
   

- Advertisement -