PDA

Click to See Complete Forum and Search --> : how to do form authentocation


PPCC
Sep 14th, 2004, 05:53 AM
I am new inasp.net, I am giving form authentication to my web site for that i have
written following code in web.config file.On compilation it is giving me error.
like unable to start your project .....
can any body help me out.

thanks & regards
PPCC

the code goes here..

<authentication mode="Forms"/>

<forms name="formsauth1" loginUrl="Login.aspx" protection="all" timeout="30" path="/">

<location path="Login.aspx"> [This can also be a folder]

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

</location>

nemaroller
Sep 14th, 2004, 06:20 AM
you closed the authentication tag too early...


<authentication mode="Forms" />

Wokawidget
Sep 15th, 2004, 10:55 AM
This is what I use:

<authentication mode="Forms">
<forms loginUrl = "Login.aspx"/>
</authentication>

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

And then in my login page I have:

Imports System.Web.Security

Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim objTicket As FormsAuthenticationTicket
Dim objCookie As HttpCookie
Dim strReturnURL As String
If ValidateLogin() Then
objTicket = New FormsAuthenticationTicket(txtUsername.Text, False, 30)
objCookie = New HttpCookie(".ASPXAUTH")
objCookie.Value = FormsAuthentication.Encrypt(objTicket)
Response.Cookies.Add (objCookie)
strReturnURL = Request.Params("ReturnURL")
If strReturnURL Is Nothing Then
Response.Redirect ("Main.aspx")
Else
Response.Redirect (strReturnURL)
End If
Else
lblMessage.Visible = True
lblMessage.Text = "Invalid username/password."
End If
End Sub

Does that help?

Woof