Authentication using xml

how to authenticate users using xml file

How to make users in XML File and authenticate them..
create a xml file as



Add two Text Boxes on Design page with ids TextBox1 and TextBox2

Add a label with id Label1
Add a button
double click on button
and write following code in button click event


//code to authenticate user
String pt = Server.MapPath("XMLFile.xml");//
DataSet ds = new DataSet();
DataView dv = ds.Tables[0].DefaultView;
dv.RowFilter = "user='" + TextBox1.Text+"'";
if (dv.Count == 0)
Label1.Text = "Wrong User";
if (dv[0][1].ToString() == TextBox2.Text)
FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false);
Label1.Text = "Wrong Password";

Run the application


Related Articles


User who is responsible for running current thread can be impersonated programmatically.

More articles: Authentication XML Impersonation Authentication Authorization


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: