Skip to content

Commit ac07155

Browse files
committed
Fixed unauthorized access issue by enforcing session authentication on index.aspx.
1 parent 7e0e06c commit ac07155

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

WebApplication2/Pages/Home/Home.aspx.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ protected void Page_Load(object sender, EventArgs e)
1313
{
1414
if (Session["adminID"] == null)
1515
{
16-
// Redirect to the login page if not authenticated
16+
Response.Write("Session is null. Redirecting...");
1717
Response.Redirect("/Pages/Login/Login.aspx");
1818
}
19-
19+
else
20+
{
21+
Response.Write("Session exists. AdminID: " + Session["adminID"]);
22+
}
2023
}
2124
}
2225
}

WebApplication2/index.aspx.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public partial class index : System.Web.UI.Page
1414
{
1515
protected void Page_Load(object sender, EventArgs e)
1616
{
17+
if (Session["adminID"] == null)
18+
{
19+
Response.Redirect("/Pages/Login/Login.aspx");
20+
}
21+
1722
string connectionString = ConfigurationManager.ConnectionStrings["Milestone2DB_24"].ConnectionString;
1823

1924
using (SqlConnection connection = new SqlConnection(connectionString))

0 commit comments

Comments
 (0)