Securing Web Applications thru Form Authentication

A

A P

Hi!

I have existing web apps that was developed under ASP. I use form
authentication by querying to a database if the user is allowed to use the
application. I have read that ASP.NET is much easier to manage this kind of
security. Can you help me with this?

Me
 
K

Ken Tucker [MVP]

Hi,

Here is some code for the login page. I placed 2 textboxes for
username and passsword and 2 required field validators on the form. The
code is just an example. In a real situation you should store the passwords
encypted. Hope this helps.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

End Sub

Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnClear.Click

txtUser.Text = ""

txtPassword.Text = ""

End Sub

Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLogin.Click

If Page.IsValid Then

If txtUser.Text = "Mike" And txtPassword.Text = "password" Then

Response.Redirect("Default.aspx")

Else

Response.Write("Invalid User !")

End If

End If

End Sub



Changes that should be made to Web.config



<authentication mode="Forms" >

<forms name="Mypubscookie" loginUrl ="Login.aspx" protection="All"
timeout="30">

</forms>

</authentication>





Ken

----------------
Hi!

I have existing web apps that was developed under ASP. I use form
authentication by querying to a database if the user is allowed to use the
application. I have read that ASP.NET is much easier to manage this kind of
security. Can you help me with this?

Me
 
A

A P

Hi Ken,

I have test it but it has an error. The debugger is pointing on the
web.config "<forms name=..." . Is there a mistake on the code that you gave?

Me
 
A

A P

Hi Ken,

I have tried again by removing other remarks on the <authorization> and it
work! Thanks for that. Btw, I have another question, I want this
authorization(login page) be shown if other user will access other webforms
under this web apps that is not yet authenticated. How can I do this?

Me
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top