Last post May 02, 2013 03:53 PM by psinet
Member
7 Points
26 Posts
May 01, 2013 04:14 AM|paresh89|LINK
Hey , I have single user application. I want to store username and password in xml file. It is like:
<userinfo> <add user="admin" password="root" /> </userinfo>
How should i read it to validate and password and change password stored in it. Please help thanks
Participant
1540 Points
462 Posts
May 01, 2013 04:38 AM|sangeeth2007|LINK
You can use app.setting if your are using a windows application
<appSettings> <add key="username" value="user"/> <add key="password" value="pwd"/> </appSettings>
use ConfigurationManager.AppSettings["username"] to read the content.
to save the data back OpenExeConfiguration.here is a good example of how to do
http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.getsection.aspx
Please add reference to System.Configuration;
make sure to encrpt the password before storing
1380 Points
316 Posts
May 02, 2013 03:53 PM|psinet|LINK
You actually don't need a seperate xml file to do this. You can store the account information in the web.config and then use the built-in FormsAuthentication to validate the account.
<forms loginUrl="~/SignIn.aspx" defaultUrl="~/Default.aspx"> <credentials passwordFormat="Clear"> <user name="testUser1" password="testPass1"/> </credentials> </forms>
Here's a write up on it, Authentication using web.config credentials.
Member
7 Points
26 Posts
XML file reading and editing
May 01, 2013 04:14 AM|paresh89|LINK
Hey , I have single user application. I want to store username and password in xml file. It is like:
How should i read it to validate and password and change password stored in it. Please help thanks
Participant
1540 Points
462 Posts
Re: XML file reading and editing
May 01, 2013 04:38 AM|sangeeth2007|LINK
You can use app.setting if your are using a windows application
use ConfigurationManager.AppSettings["username"] to read the content.
to save the data back OpenExeConfiguration.here is a good example of how to do
http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.getsection.aspx
Please add reference to System.Configuration;
make sure to encrpt the password before storing
Participant
1380 Points
316 Posts
Re: XML file reading and editing
May 02, 2013 03:53 PM|psinet|LINK
You actually don't need a seperate xml file to do this. You can store the account information in the web.config and then use the built-in FormsAuthentication to validate the account.
Here's a write up on it, Authentication using web.config credentials.