Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

error on r egister

$
0
0

I am doing  a tutorial for entity framework and aspent.Identity. Making a register.aspx page. When I run it I get errors. "the name 'Password' does not exist in the current context".

c#

using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using System;
using System.Linq;

namespace WebFormsIdentity
{
    public partial class Register : System.Web.UI.Page
    {
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            // Default UserStore constructor uses the default connection string named: DefaultConnection
            var userStore = new UserStore<IdentityUser>();
            var manager = new UserManager<IdentityUser>(userStore);

            var user = new IdentityUser() { UserName = UserName.Text };
            IdentityResult result = manager.Create(user, Password.Text);

            if (result.Succeeded)
            {
                StatusMessage.Text = string.Format("User {0} was created successfully!", user.UserName);
            }
            else
            {
                StatusMessage.Text = result.Errors.FirstOrDefault();
            }
        }
    }
}

 designer code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="WebApplicationId.Register" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title></title></head><body style="font-family: Arial, Helvetica, sans-serif; font-size: small"><form id="form1" runat="server"><div><h4 style="font-size: medium">Register a new user</h4><p><asp:Literal runat="server" ID="StatusMessage" /></p><div style="margin-bottom:10px"><asp:Label runat="server" AssociatedControlID="UserName">User name</asp:Label><div><asp:TextBox runat="server" ID="UserName" /></div></div><div style="margin-bottom:10px"><asp:Label runat="server" AssociatedControlID="Password">Password</asp:Label><div><asp:TextBox runat="server" ID="Password" TextMode="Password" /></div></div><div style="margin-bottom:10px"><asp:Label runat="server" AssociatedControlID="ConfirmPassword">Confirm password</asp:Label><div><asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" /></div></div><div><div><asp:Button runat="server" OnClick="CreateUser_Click" Text="Register" /></div></div></div></form></body></html>

I have references to:

Microsoft.AspNet.Identity.EntityFramework

Microsoft.AspNet.Identity.Core

EntityFramework.SqlServer.dll

EntityFramework

I don't see what the  problem is???


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>