use Generic Handler[Global.asax] file
C# code
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
}
void Application_End(object sender, EventArgs e)
{
}
void Application_Error(object sender, EventArgs e)
{
}
void Session_Start(object sender, EventArgs e)
{
Session["Authenticate"] = "";
CheckLogin();
}
void Session_End(object sender, EventArgs e)
{
CheckLogin();
}
void Application_OnPostRequestHandlerExecute()
{
}
void CheckLogin()
{
string Url = Request.RawUrl;
int count = Url.Length - 10;
string TestUrl = Url.Substring(count);
string SessionData = Session["Authenticate"].ToString();
if (SessionData == "" && TestUrl != "Login.aspx")
{
Response.Redirect("~/Login.aspx");
}
}
</script>
put the code in login page.cs
Session["Authenticate"] = "Yes";