i want to disable the back button of the browser after the user has logged out.
for this i wrote this below code in pageload of the master page
If Session("UserName") = Nothing Or Session("UserRole") <> "Admin" Then
Session("ErrMsg") = "Session Expired or Access Denied please login"
Response.Redirect("../Login.aspx")
End If
Can you not write your own security module and return the user to the login page if the select the back button? It would be a little neater than what your trying to do and is also how the .NET Frameworks version works!
The security module only has to do something that you have performed. Intercept the request, check to see if the sessions are null, if they are then they are loged out so redirect to login page!
You can't clear the user's browser history - that is outside of the scope of
the permissions that a web application has granted. What you can do is
explicitly check on each page whether the user is logged in, and if not do a
response.redirect.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session("Uname") = Nothing Then
Response.Redirect("~/Login.aspx")
End If
Response.Buffer = True
Response.ExpiresAbsolute = DateTime.Now().AddDays(-1)
Response.Expires = -1500
Response.CacheControl = "no-cache"
End Sub
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
If txtUname.Text = "User" And txtPwd.Text = "User" Then
Session("Uname") = txtUname.Text
Session("pwd") = txtPwd.Text
Response.Redirect("User/home.aspx")
Else
lblMsg.Text = "Invalid User / Pwd"
End If
End Sub
Logout.aspx
<body >
<form id="form1" runat="server">
<div>
Would u like to login again <a href="login.aspx" runat="server" >Click Here</a>
<br />
<asp:Label ID="lblMsg" runat="server" ></asp:Label>
</div>
</form>
</body>
Code Behind for Logout page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Session.Abandon()
Session.Clear()
End Sub
After the user logouts and clicks the back button of the firefox browser then page is dislplayed from which he logouts
ex :If user id in Page2.aspx and clicks logout ,and clicks back button then page2.aspx is displayed even after clearing the sessions.
In each page i'm checking the session also but still the page is displayed when back button of the browser is clicked after user loged out.
When you click logout button,place and intermediate page which just redirect the page to logout.aspx.
I have solved this probs like this way.
If either from page2 or from page1 when user click logout it will redirect to this intermediate page and then go to logout page, so next time when you click back,it remains as it is.
after the user logouts and clicks the back button of the browser he shouldn't go to the previous page.only login page to be displayed
Hi archu136,
To prevent the logout user from returning the preious page by clicking the back button, I have provided a solution (with the help of cookie) in the following thread. Also, you can use “NC01”’s solution in that thread.
Sincerely,
Benson Yu
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
archu136
Member
27 Points
96 Posts
How to clear the browsing history of the firefox using asp.net
Jan 23, 2008 05:28 AM|LINK
hi frds
i want to disable the back button of the browser after the user has logged out.
for this i wrote this below code in pageload of the master page
If Session("UserName") = Nothing Or Session("UserRole") <> "Admin" Then
Session("ErrMsg") = "Session Expired or Access Denied please login"
Response.Redirect("../Login.aspx")
End If
Response.Buffer = True
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ExpiresAbsolute = DateTime.Now().AddDays(-1)
Response.Expires = -1500
Response.CacheControl = "no-cache"
this is working fine in IE but not in firefox.
i have searched for this but didn't get the solution.
if i could clear the histroy of the firefox then after the user logouts and clicks the back button of the
browser he shouldn't go to the previous page.only login page to be displayed
plz help me
thank u in advance
ARCHU
DavidKiff
Star
8660 Points
1733 Posts
Re: How to clear the browsing history of the firefox using asp.net
Jan 23, 2008 10:30 AM|LINK
Can you not write your own security module and return the user to the login page if the select the back button? It would be a little neater than what your trying to do and is also how the .NET Frameworks version works!
The security module only has to do something that you have performed. Intercept the request, check to see if the sessions are null, if they are then they are loged out so redirect to login page!
Visit my site
Follow me on Twitter
nikhil.agraw...
Member
470 Points
90 Posts
Re: How to clear the browsing history of the firefox using asp.net
Jan 23, 2008 10:49 AM|LINK
Pl. find solution at my previous post
http://forums.asp.net/t/1209466.aspx
Think before you Think
dharnendra
Contributor
2955 Points
551 Posts
Re: How to clear the browsing history of the firefox using asp.net
Jan 23, 2008 12:46 PM|LINK
You can't clear the user's browser history - that is outside of the scope of
the permissions that a web application has granted. What you can do is
explicitly check on each page whether the user is logged in, and if not do a
response.redirect.
Technical Leader
GTL-Ahmedabad
archu136
Member
27 Points
96 Posts
Re: How to clear the browsing history of the firefox using asp.net
Jan 24, 2008 05:38 AM|LINK
Hi
ok if that is not possible then can we disable the back button of the browser after the user has loged out
this is my sample application.I'm facing this problem in Firefox
I'm Using the Master Page in my application & under User Folder ,2 aspx pages
1)MasterPage.Master
2)login.aspx
3)Logout.aspx
4)User/Page1.aspx
5)User/page2.aspx and User/home.aspx
MasterPage.Master
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Master Page</title>
</head>
<body >
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<table>
<tr>
<td><a href="User/Page1.aspx" runat="server">Page1</a></td>
</tr>
<tr>
<td><a href="User/Page2.aspx" runat="server">Page2</a></td>
</tr>
<tr>
<td>
<a href="logout.aspx" runat="server">Logout</a>
</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</td>
</tr>
</table>
</td>
</tr></table>
</div>
</form>
</body>
</html>
Code For MAsterPage.Master
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session("Uname") = Nothing Then
Response.Redirect("~/Login.aspx")
End If
Response.Buffer = True
Response.ExpiresAbsolute = DateTime.Now().AddDays(-1)
Response.Expires = -1500
Response.CacheControl = "no-cache"
End Sub
Login.aspx
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>UID:
<asp:TextBox ID="txtUname" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>PWD :
<asp:TextBox ID="txtPwd" runat="server" ></asp:TextBox>
</td>
</tr>
<tr>
<td><asp:Button ID="btnLogin" runat="server" Text="Login" /></td>
</tr>
<tr>
<td>
<asp:Label ID="lblMsg" runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
CodeBehind of Login.aspx
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
If txtUname.Text = "User" And txtPwd.Text = "User" Then
Session("Uname") = txtUname.Text
Session("pwd") = txtPwd.Text
Response.Redirect("User/home.aspx")
Else
lblMsg.Text = "Invalid User / Pwd"
End If
End Sub
Logout.aspx
<body >
<form id="form1" runat="server">
<div>
Would u like to login again <a href="login.aspx" runat="server" >Click Here</a>
<br />
<asp:Label ID="lblMsg" runat="server" ></asp:Label>
</div>
</form>
</body>
Code Behind for Logout page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Session.Abandon()
Session.Clear()
End Sub
After the user logouts and clicks the back button of the firefox browser then page is dislplayed from which he logouts
ex :If user id in Page2.aspx and clicks logout ,and clicks back button then page2.aspx is displayed even after clearing the sessions.
In each page i'm checking the session also but still the page is displayed when back button of the browser is clicked after user loged out.
this is the problem hope u understood
thanks and regards
ARCHU
dharnendra
Contributor
2955 Points
551 Posts
Re: How to clear the browsing history of the firefox using asp.net
Jan 25, 2008 12:01 PM|LINK
I have one solution for that problem.
When you click logout button,place and intermediate page which just redirect the page to logout.aspx.
I have solved this probs like this way.
If either from page2 or from page1 when user click logout it will redirect to this intermediate page and then go to logout page, so next time when you click back,it remains as it is.
Technical Leader
GTL-Ahmedabad
archu136
Member
27 Points
96 Posts
Re: How to clear the browsing history of the firefox using asp.net
Jan 28, 2008 11:16 AM|LINK
Hi
I have tried this ie redirecting to intermediate page but still facing the same problem
can u send the code if possible.
Thanks and Regards
ARCHU
Benson Yu - ...
All-Star
34797 Points
2497 Posts
Re: How to clear the browsing history of the firefox using asp.net
Jan 29, 2008 07:49 AM|LINK
Hi archu136,
To prevent the logout user from returning the preious page by clicking the back button, I have provided a solution (with the help of cookie) in the following thread. Also, you can use “NC01”’s solution in that thread.
disable back button of browser so that a user can't go on previous pages after signout
http://forums.asp.net/p/1161997/1923379.aspx
Benson Yu
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
ketan.raval....
Member
486 Points
125 Posts
Re: How to clear the browsing history of the firefox using asp.net
Jan 29, 2008 11:03 AM|LINK
play with following javascript functions
history.forward() and history.go()
This will surely helps you
thanks
ketan
Letsnurture
Ketan's Leadership Blog
Ketan's Nurture Blog
ketan.raval....
Member
486 Points
125 Posts
Re: How to clear the browsing history of the firefox using asp.net
Jan 29, 2008 11:05 AM|LINK
http://www.atmos.washington.edu/~ovens/javascript/jseg23.html
Letsnurture
Ketan's Leadership Blog
Ketan's Nurture Blog