Click here to Skip to main content
12,702,596 members (34,421 online)
Rate this:
Please Sign up or sign in to vote.
See more: XML
Hi I am a new user of ASp.NET. I was just surfing and was curious to know how i can store information like a database in XML and later use it in Login purpose type example.
Posted 6-Oct-12 8:19am
Zoltán Zörgő 6-Oct-12 14:51pm
Store a database in an xml? Where: on client or on the server? And why?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

What I understand from your question is you want to login into a ASP.NET website making use of a XML file. XML file contains login username-password information and you want to use it for authentication. If so, look at the following:
Video: How To Pull Data From An XML File Using ASP.NET[^]
Login using XML file in ASP.NET using C#[^]
Form Authentication in ASP.NET using XML[^]

<?xml version="1.0" encoding="utf-8" ?>

Code behind:
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
string username;
string pwd;
string CurrentUser = "";
string CurrentPwd = "";
bool LoginStatus = false;
username = Login1.UserName;
pwd = Login1.Password;
XmlDocument xmxdoc = new XmlDocument();
XmlNodeList xmlnodelist = xmxdoc.GetElementsByTagName("User");
foreach (XmlNode xn in xmlnodelist)
XmlNodeList xmlnl = xn.ChildNodes;
foreach (XmlNode xmln in xmlnl)
if (xmln.Name == "username")
if (xmln.InnerText == username)
CurrentUser = username;
if (xmln.Name == "password")
if (xmln.InnerText == pwd)
CurrentPwd = pwd;
if ((CurrentUser != "") & (CurrentPwd != ""))
LoginStatus = true;
if (LoginStatus == true)
Session["UserAuthentication"] = username;
Session.Timeout = 1;
Session["UserAuthentication"] = "";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 7 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100