Cynthia

Cynthia

  • NA
  • 215
  • 35.9k

How to save username & password locally in .Net application?

May 29 2017 6:31 AM
I am creating a login screen for which i have to save username & password locally so that next time when user login it doesn't ask for login .
I have used this code to save
Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add("UserName"username);
config.AppSettings.Settings.Add("Password ",userpasssword);
config.Save();
System.Configuration.ConfigurationManager.RefreshSection("appSettings");
 
I am working in debug mode in VS2015 , first the username & password are written to myapp.vshost.exe.config file & once i close application , it is not saved . So, next time when user login ,again it will ask for password .
 
My question are -:How it will be saved permanently so that it exists even if application is closed so that next time when user login it doesn't ask for login credentials ? 
is my approach correct or not ? 
 

Answers (1)