Hi experts,
In my Web application, I am having two pages.
1.LoginPage.aspx
2.MainPage.aspx
controls used in Loginpage
username text box
Password text box
Button
while running
http:
then the authentication success on the button click we redirecting to
Response.Redirect("~/MainPage.aspx");
without authentication if you use the below URL
http:
its going to mainpage.aspx
my problem is if use this URL should be redirected to LoginPage only.
I have searched many examples in Google.But I haven't get the clear solution.
kindly explain me to achieve this.
I have master page and I tried like,
1. in my web.config file
<authentication mode="Forms">
<forms loginUrl="Login.aspx" timeout="1" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
2. and my Login file, we have many images and headers then my button click event
protected void Login_Click(object sender, EventArgs e)
{
if ((UserEmail.Value == "12") && (UserPass.Value == "12"))
{
FormsAuthentication.RedirectFromLoginPage(UserEmail.Value, true);
Response.Redirect("MainPage.aspx");
}
else
{
Msg.Text = "Invalid Credentials: Please try again";
}
}
3. My WebForm1 file like one logout button click event.
FormsAuthentication.SignOut();
Response.Redirect("Login.aspx");
If i run this application my design changed and images were not displayed on the browser.
if i use this part in web.config file
<authorization>
<deny users="?" />
</authorization>
design and images were not displayed properly but i am able to redirect login page when other URL typed in the browser, if i remove this tag design is ok but i am unable to redirect to login page when other URL typed in the browser.