Problem in forms auth, not going back to members page

G

Guest

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.
 
G

Guest

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
 
D

DM McGowan II

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".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top