簡體   English   中英

用戶詳細信息保存在asp.net身份中

[英]user details save in asp.net identity

我具有以下POST方法來保存編輯用戶詳細信息:

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Edit_User(EditUserViewModel editUser, HttpPostedFileBase upload)
{
    var store = new UserStore<ApplicationUser>(new DBEntities());

    try
    {
        if (ModelState.IsValid)
        {
            var user = await UserManager.FindByIdAsync(editUser.Id);

            if (user == null)
            {
                return HttpNotFound();
            }

            user.UserName = editUser.UserName;
            user.Email = editUser.Email;
            ...

            // update the user information

            await UserManager.UpdateAsync(user);
            var ctx = store.Context;
            ctx.SaveChanges();

            return RedirectToAction("Method", "Controller");
        }
    }

    catch (Exception ex)
    {
        return View(editUser);
    }

    return View(editUser);
}

但是在這里,一旦將數據保存到AspNetUser表中,我就不會收到任何錯誤,它正在跳轉以捕獲異常。

如何正確保存此編輯用戶詳細信息?

您是否使用以下方法更改了密鑰: http : //www.asp.net/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity

其中包含以下步驟。 您需要確保獲得每個正確的答案。

Change the type of the key in the Identity user class
Add customized Identity classes that use the key type
Change the context class and user manager to use the key type
Change start-up configuration to use the key type
For MVC with Update 2, change the AccountController to pass the key type
For MVC with Update 3, change the AccountController and ManageController to pass the key type

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM