需要显示存储在AspNetUser表中的某些值

时间:2019-04-22 19:03:11

标签: c# asp.net asp.net-identity

我正在使用下面的代码来查看是否可以显示存储在AspNetUser表中的Description,数量,价格和Value的值。我在第二个“ IF”中的第一次尝试并没有产生 除了用户ID。 我继续添加了最后三行,但是最后一行中的“字符串”没有被接受。

请有人提出想法!!

 public partial class Account : System.Web.UI.Page
{
    public string Description { get; internal set; }
    public string Quantity { get; internal set; }
    public string Price { get; internal set; }
    public string Value { get; internal set; }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (User.Identity.IsAuthenticated)
            {
                StatusText.Text = string.Format("Hello {0}!! ", User.Identity.GetUserName(), Description, Quantity, Price, Value);
                LoginStatus.Visible = true;
                LogoutButton.Visible = true;
            }
            else
            {
                LoginForm.Visible = true;
            }
        }
        var userStore = new UserStore<IdentityUser>();
        var userManager = new UserManager<IdentityUser>(userStore);
        var user = userManager.string(Description, Quantity, Price, Value);

    }
}

1 个答案:

答案 0 :(得分:0)

I removed the last three statements above and added two other lines in their place so i now have below:

public partial class Account : System.Web.UI.Page
{
public string Description { get; internal set; }
public string Quantity { get; internal set; }
public string Price { get; internal set; }
public string Value { get; internal set; }
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        if (User.Identity.IsAuthenticated)
    {
     StatusText.Text = string.Format("Hello {0}!! ", User.Identity.GetUserName(), Description, Quantity, Price, Value);                                         
     LoginStatus.Visible = true;
     LogoutButton.Visible = true;
        }
        else
        {
            LoginForm.Visible = true;
        }
    }
    var user = HttpContext.Current.GetOwinContext().Get<ApplicationUserManager>  ().FindById(User.Identity.GetUserId());
    Response.Write(user.Description + "" + user.Quantity + "" + user.Price + "" + user.Value);

}

}

I have not run it yet but all the parameters were accepted in development.