Add below code to your configuration file.(Sample code to have idea how to implement such things)
<system.web>
<authentication mode="Forms">
<forms loginUrl="logon.aspx" name=".ASPXFORMSAUTH">
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
Implement something like:
void Logon_Click(object sender, EventArgs e)
{
if ((UserEmail.Text == "xyz@domain.com") &&
(UserPass.Text == "12345"))
{
FormsAuthentication.RedirectFromLoginPage
(UserEmail.Text, Persist.Checked);
}
else
{
Msg.Text = "Invalid credentials. Please try again.";
}
}
When any unauthenticated user tries to open any page,she will be automatically redirected to logon page.Once she provides correct username and password,then she will be redirected to the page she was requesting previously.
Happy coding.. :laugh: