Click here to Skip to main content
15,744,607 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I developing one web application where i have three Page
1. login.aspx
2. Default.aspx
3. Default2.aspx
i have used form authentication
and my web.config file setting is like below
<authentication mode="Forms">
			<forms loginUrl="Login.aspx" cookieless="AutoDetect">
			<deny users="?" />

i want request made to any page will take to login page if user is not authenticate.
after authentication it should go to Default1.aspx . This should happen alway if any
unauthenticated request is made to Default2.aspx. but its not happening if unauthenticated request is made to default2.aspx page it first takes to login.aspx and after successful authentication it take to default.aspx page which i don require
login logic is as follows
if ((UserEmail.Text == "") &&
           (UserPass.Text == "37Yj*99Ps"))
                   (UserEmail.Text, Persist.Checked);
                Msg.Text = "Invalid credentials. Please try again.";

if any unauthenticated request is made to default2.aspx the url show in address bar is http://localhost:3793/Login.aspx?ReturnUrl=%2fdefault2.aspx.
i want to url come only http://localhost:3793/login.aspx even if any unauthenticated request is made to default2.aspx
Updated 10-May-11 20:34pm

First of all don't use


Instead u can set Defaulturl in your config file like.

<forms loginUrl="Login.aspx" defaulturl="Login.aspx" cookieless="AutoDetect">

and on Your logout button don't use


Instead u can use

FormsAuthentication.SetAuthCookie(lblUserName.Text, false);
            Response.Redirect("Login.aspx", false);

Which solves ur url problem.

Hope it helps......
Share this answer
spydeehunk 11-May-11 3:49am    
not working accordingly what i need
and else part (if any unauthenticated ) again you redirect to login.aspx instead of default2.aspx
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900