-2

I am using forms authentication with username and password stored inside web.config, is there anyway that I can modify web.config programmatically through another aspx file so that my users are able to change their password ?

drhanlau
  • 2,517
  • 2
  • 24
  • 42
  • 5
    username and password stored inside web.config???????? – Murali Murugesan May 30 '14 at 13:17
  • Web.Config uses an xml-setup. You could read it out from another program and edit its values. But why not use a database? – Matthijs May 30 '14 at 13:17
  • @Matthijs I am storing information for a single user only, therefore a database setup is overkill – drhanlau May 30 '14 at 13:19
  • @cherhan: That changes your question; "users" turning into "user". Be clear when asking questions! Also, the link LittleBobbyTables provided should help you out. – Matthijs May 30 '14 at 13:20
  • For those wondering why am I storing username and password in Web.config, see this http://msdn.microsoft.com/en-us/library/vstudio/7t6b43z4(v=vs.100).aspx – drhanlau May 30 '14 at 13:24

1 Answers1

0

With the help of 'WebConfigurationManager' class you can easily do it,

see below snippet

var szCongigMan = WebConfigurationManager.OpenWebConfiguration("~");
var connectionstringSection = (ConnectionStringsSection)szCongigMan.GetSection("connectionStrings");
connectionstringSection.ConnectionStrings["MyConnectionString"].ConnectionString = "Data Source=...";
szCongigMan.Save();
koolprasad2003
  • 299
  • 3
  • 23