By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,777 Members | 1,311 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,777 IT Pros & Developers. It's quick & easy.

Problem in forms auth, not going back to members page

P: n/a
1. Created a new C# web application project
2. Change the name of webform1 to login.aspx
3. And in the .cs file change the name of the class to login, and include
System.web.security namespace.
4. Place a textbox and a button in the login.aspx form.
5. Have the following code in the button click event.

if (true)
{
FormsAuthentication.RedirectFromLoginPage(TextBox1 .Text, false)
}

6. Go to the web.config file, and change authentication from windows to Forms.

<authentication mode="Forms" />
and
<authorization>
<allow users="*" />
</authorization>

7. From the project menu, add new folder and name it as 'members'. Go to IIS
and
make this folder as an application.
8. Add a new webform to this sub-folder and name it as membersonly.aspx.
9. Place a label on the form.
10. Paste this code in the page load method.

if (Context.User.Identity.IsAuthenticated)
Label1.Text = "User Successfully Authenticated " + User.Identity.Name;
else
Label1.Text = "Authentication Failed. This Sucks";

11. With in this folder, add a new item, web.config file.
12. for authentication, paste this

<authentication mode="Forms">
<forms name="uslandcoauth" loginUrl="../Login.aspx" path="/"
protection="All"></forms>
</authentication>

13. for authorization, paste this

<authorization>
<deny users="?" />
</authorization>

Build the solution, open a browser and go to the membersonly.aspx page.
It gets redirected to login.aspx, this is fine because the user is not
authenticated.
Enter your name in the text box and click the button.
But it does not go to the membersonly.aspx page. It gets refreshed and shows
the same login page.

Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Can any one tell me what is the problem with the above. I am working on this
for quite some time now and I am not able to figure out the problem.

TAI
Senthil

"Senthil" wrote:
1. Created a new C# web application project
2. Change the name of webform1 to login.aspx
3. And in the .cs file change the name of the class to login, and include
System.web.security namespace.
4. Place a textbox and a button in the login.aspx form.
5. Have the following code in the button click event.

if (true)
{
FormsAuthentication.RedirectFromLoginPage(TextBox1 .Text, false)
}

6. Go to the web.config file, and change authentication from windows to Forms.

<authentication mode="Forms" />
and
<authorization>
<allow users="*" />
</authorization>

7. From the project menu, add new folder and name it as 'members'. Go to IIS
and
make this folder as an application.
8. Add a new webform to this sub-folder and name it as membersonly.aspx.
9. Place a label on the form.
10. Paste this code in the page load method.

if (Context.User.Identity.IsAuthenticated)
Label1.Text = "User Successfully Authenticated " + User.Identity.Name;
else
Label1.Text = "Authentication Failed. This Sucks";

11. With in this folder, add a new item, web.config file.
12. for authentication, paste this

<authentication mode="Forms">
<forms name="uslandcoauth" loginUrl="../Login.aspx" path="/"
protection="All"></forms>
</authentication>

13. for authorization, paste this

<authorization>
<deny users="?" />
</authorization>

Build the solution, open a browser and go to the membersonly.aspx page.
It gets redirected to login.aspx, this is fine because the user is not
authenticated.
Enter your name in the text box and click the button.
But it does not go to the membersonly.aspx page. It gets refreshed and shows
the same login page.

Jul 21 '05 #2

P: n/a
Not sure but try changing:

<forms name="uslandcoauth" loginUrl="../Login.aspx" path="/"
protection="All"></forms>

to use a relative path spec from the web root like "/Login.aspx" or
"/AppName/Login.aspx".

"Senthil" <Se*****@discussions.microsoft.com> wrote in message
news:83**********************************@microsof t.com...
Can any one tell me what is the problem with the above. I am working on this for quite some time now and I am not able to figure out the problem.

TAI
Senthil

"Senthil" wrote:
1. Created a new C# web application project
2. Change the name of webform1 to login.aspx
3. And in the .cs file change the name of the class to login, and include System.web.security namespace.
4. Place a textbox and a button in the login.aspx form.
5. Have the following code in the button click event.

if (true)
{
FormsAuthentication.RedirectFromLoginPage(TextBox1 .Text, false)
}

6. Go to the web.config file, and change authentication from windows to Forms.
<authentication mode="Forms" />
and
<authorization>
<allow users="*" />
</authorization>

7. From the project menu, add new folder and name it as 'members'. Go to IIS and
make this folder as an application.
8. Add a new webform to this sub-folder and name it as membersonly.aspx.
9. Place a label on the form.
10. Paste this code in the page load method.

if (Context.User.Identity.IsAuthenticated)
Label1.Text = "User Successfully Authenticated " + User.Identity.Name;
else
Label1.Text = "Authentication Failed. This Sucks";

11. With in this folder, add a new item, web.config file.
12. for authentication, paste this

<authentication mode="Forms">
<forms name="uslandcoauth" loginUrl="../Login.aspx" path="/"
protection="All"></forms>
</authentication>

13. for authorization, paste this

<authorization>
<deny users="?" />
</authorization>

Build the solution, open a browser and go to the membersonly.aspx page.
It gets redirected to login.aspx, this is fine because the user is not
authenticated.
Enter your name in the text box and click the button.
But it does not go to the membersonly.aspx page. It gets refreshed and shows the same login page.


Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.