Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
521 Points
469 Posts
Feb 28, 2012 05:20 PM|LINK
Dave Sussman Right. I wasn't sure whether you meant the physical web.config file, or the values as loaded at runtime. Try Configuration configFile = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~"); System.Web.Configuration.MembershipSection section = (System.Web.Configuration.MembershipSection)configFile.GetSection("system.web/membership"); ProviderSettings settings = section.Providers["AspNetSqlMembershipProvider"]; settings.Parameters["minRequiredPasswordLength"] = "3"; settings.Parameters["minRequiredNonalphanumericCharacters"] = "3"; configFile.Save();
Right. I wasn't sure whether you meant the physical web.config file, or the values as loaded at runtime. Try
Configuration configFile = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~"); System.Web.Configuration.MembershipSection section = (System.Web.Configuration.MembershipSection)configFile.GetSection("system.web/membership"); ProviderSettings settings = section.Providers["AspNetSqlMembershipProvider"]; settings.Parameters["minRequiredPasswordLength"] = "3"; settings.Parameters["minRequiredNonalphanumericCharacters"] = "3"; configFile.Save();
Hi I tried almost this code (not exact) and I fall down into errors today in noon. And then I had to restore the config file again.
So I want to know is it the safest way to update web.config file or try something else.
Thanks
sophia_asp
Member
521 Points
469 Posts
Re: access sub elements of membership provider
Feb 28, 2012 05:20 PM|LINK
Hi I tried almost this code (not exact) and I fall down into errors today in noon. And then I had to restore the config file again.
So I want to know is it the safest way to update web.config file or try something else.
Thanks