Ref:Login , Security failure when user click Back button??
hi I am about to deploy my web application but I need to have some kind of security on the
pages.
I have total of 5 aspx pages in my web application. I have created a login.aspx and
a default.aspx. The user first will put his username and password, then once he/she click
login, he will be directed to the default.aspx, where there is a menu at the top of all
aspx pages for navigation.
The login.aspx works fine to verify the user's name and password,so he/she can view all pages.
but when the user click on log out button, he will be directed to the login.aspx page.
this is perfect....... here is the problem.
if someone else used the same computer, and click on the back button on the browser, he will
view all the aspx pages.. so there is no security, not only that if another person who is not
authorized copied the URL address and saved it , he will always be able to log into the site
and view all the pages.
How can I prevent such thing. Here is the code I am using to create the login.aspx
<%@ Import Namespace="System.Web.Security " %>
<html>
<script language="VB" runat=server>
Sub Login_Click(Src As Object, E As EventArgs)
If (UserName.Value = "bob" Or UserName.Value = "Mark"
And UserPass.Value = "Guest"
FormsAuthentication.RedirectFromLoginPage(UserName.Value, PersistCookie.Checked)
Else
Msg.Text = "Invalid Credentials: Please try again"
End If
End Sub
</script>
<body>
<form runat=server>
<h3><font face="Verdana">Login Page</font></h3>
<table>
<tr>
<td>Email:</td>
<td><input id="UserName" type="text" runat=server/></td>
<td><ASP:RequiredFieldValidator ControlToValidate="UserName" Display="Static" ErrorMessage="*" runat=server/></td>
</tr>
<tr>
<td>Password:</td>
<td><input id="UserPass" type=password runat=server/></td>
<td><ASP:RequiredFieldValidator ControlToValidate="UserPass" Display="Static" ErrorMessage="*" runat=server/></td>
</tr>
<tr>
<td>Persistent Cookie:</td>
<td><ASP:CheckBox id=PersistCookie runat="server" /> </td>
<td></td>
</tr>
</table>
<asp:button text="Login" OnClick="Login_Click" runat=server/>
<p>
<asp:Label id="Msg" ForeColor="red" Font-Name="Verdana" Font-Size="10" runat=server />
</form>
</body>
</html>
====================
This is what is in the config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="MyDb"
value="server=(local); database=myDB; integrated security=SSPI"/>
</appSettings>
</configuration>
I appreciate your help in guiding me to the best way to secure my site.
thanks alot
Al
hi I am about to deploy my web application but I need to have some kind of security on the
pages.
I have total of 5 aspx pages in my web application. I have created a login.aspx and
a default.aspx. The user first will put his username and password, then once he/she click
login, he will be directed to the default.aspx, where there is a menu at the top of all
aspx pages for navigation.
The login.aspx works fine to verify the user's name and password,so he/she can view all pages.
but when the user click on log out button, he will be directed to the login.aspx page.
this is perfect....... here is the problem.
if someone else used the same computer, and click on the back button on the browser, he will
view all the aspx pages.. so there is no security, not only that if another person who is not
authorized copied the URL address and saved it , he will always be able to log into the site
and view all the pages.
How can I prevent such thing. Here is the code I am using to create the login.aspx
<%@ Import Namespace="System.Web.Security " %>
<html>
<script language="VB" runat=server>
Sub Login_Click(Src As Object, E As EventArgs)
If (UserName.Value = "bob" Or UserName.Value = "Mark"
FormsAuthentication.RedirectFromLoginPage(UserName.Value, PersistCookie.Checked)
Else
Msg.Text = "Invalid Credentials: Please try again"
End If
End Sub
</script>
<body>
<form runat=server>
<h3><font face="Verdana">Login Page</font></h3>
<table>
<tr>
<td>Email:</td>
<td><input id="UserName" type="text" runat=server/></td>
<td><ASP:RequiredFieldValidator ControlToValidate="UserName" Display="Static" ErrorMessage="*" runat=server/></td>
</tr>
<tr>
<td>Password:</td>
<td><input id="UserPass" type=password runat=server/></td>
<td><ASP:RequiredFieldValidator ControlToValidate="UserPass" Display="Static" ErrorMessage="*" runat=server/></td>
</tr>
<tr>
<td>Persistent Cookie:</td>
<td><ASP:CheckBox id=PersistCookie runat="server" /> </td>
<td></td>
</tr>
</table>
<asp:button text="Login" OnClick="Login_Click" runat=server/>
<p>
<asp:Label id="Msg" ForeColor="red" Font-Name="Verdana" Font-Size="10" runat=server />
</form>
</body>
</html>
====================
This is what is in the config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="MyDb"
value="server=(local); database=myDB; integrated security=SSPI"/>
</appSettings>
</configuration>
I appreciate your help in guiding me to the best way to secure my site.
thanks alot
Al