Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8449319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:40:12+00:00 2026-06-10T10:40:12+00:00

I was writing code for changing the passwords but I don’t know the reason

  • 0

I was writing code for changing the passwords but I don’t know the reason why the data is not updated to the database. I have built custom membership table and membership Provider class. Here enitiy named IVRControlPanelEntities is generated from entity framework. I have following function to change password.

 public bool ChangePassword(string username, string oldPassword, string newPassword)
        {
            IVRControlPanelMembershipProvider memberservice = new IVRControlPanelMembershipProvider();
            if (!memberservice.ValidateUser(username, oldPassword) || string.IsNullOrEmpty(newPassword.Trim()))
            {
                return false;
            }
            else
            {
                using (IVRControlPanelEntities db = new IVRControlPanelEntities())
                {
                    User user = GetUser(username);
                   // string hash = FormsAuthentication.HashPasswordForStoringInConfigFile(newPassword.Trim(), "md5");
                    string PasswordSalt = CreateSalt();
                    user.PasswordSalt = PasswordSalt;
                    user.Password = CreatePasswordHash(newPassword, PasswordSalt);
                    db.SaveChanges();


                }
               return true;
            }

        }

Problems:
I try changing the password, all is working fine but data for new password is not updated to the table. I have also searched for reason and use following code:
1.

db.Entry(user).State = EntityState.Modified;

2.

db.Users.Attach(user);
                 db.ApplyCurrentValues("Users", user);

None of above is working and also use TryUpdateModel() function but it’s not detecting .

It may be due to state of object is not defined, how can I solve this problem

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:40:14+00:00Added an answer on June 10, 2026 at 10:40 am

    If method GetUser uses different context, then data will not be updated.

    Try this:

    User user = db.Users.FirstOrDefault(x=>x.UserName == username);
                   // string hash = FormsAuthentication.HashPasswordForStoringInConfigFile(newPassword.Trim(), "md5");
                    string PasswordSalt = CreateSalt();
                    user.PasswordSalt = PasswordSalt;
                    user.Password = CreatePasswordHash(newPassword, PasswordSalt);
                    db.SaveChanges();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing code to clone object but have no cue from Hobo documentation.
I am writing code for a database to fetch data in an activity which
I have been writing C code for many years, but I recently came accross
I have a weird question. I have been writing a code to change the
I am changing minesweeper.exe in order to have an understanding of how code injection
I'm writing some C++ code that manipulates a bunch of vectors that are changing
I'm writing a module to act on data being sent to a database from
I'm writing PHP code that uses a database. To do so, I use an
When writing code, I often place debug messages in the code. The debug messages
While writing code in a file that would comprise of PHP, HTML, CSS &

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.