本文整理汇总了C#中WebApplication1.Models.ApplicationUser类的典型用法代码示例。如果您正苦于以下问题:C# ApplicationUser类的具体用法?C# ApplicationUser怎么用?C# ApplicationUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationUser类属于WebApplication1.Models命名空间,在下文中一共展示了ApplicationUser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CharacterChartDbModel
// Konstruktor uzupełniający model o dane użytkownika. Jest on uzupełnieniem
// konstruktora tworzącego kompletny obiekt, dlatego niektóre pola będą NULL.
public CharacterChartDbModel(
ApplicationUser user
) : this()
{
if (user != null) CreatorUserID = user.Id;
else CreatorUserID = null;
}
开发者ID:Hedonista,项目名称:RPGonline,代码行数:9,代码来源:ChartModel.cs
示例2: SaveCollage
public ActionResult SaveCollage(string userID, string stringedJSON, int collageID)
{
ApplicationDbContext Context = new ApplicationDbContext();
ApplicationUser User = new ApplicationUser();
foreach (var i in Context.Users)
{
if (i.UserName == userID)
User = i;
}
Collages newCollage = new Collages();
newCollage.userID = User.Id;
newCollage.collageInfo = stringedJSON;
if (collageID == 0)
{
Context.Collages.Add(newCollage);
Context.Entry(newCollage).State = System.Data.Entity.EntityState.Added;
}
else
{
Context.Collages.Find(collageID).collageInfo = stringedJSON;
}
Context.SaveChanges();
return RedirectToAction("Index");
}
开发者ID:Senfer,项目名称:Collages,代码行数:26,代码来源:HomeController.cs
示例3: CharacterDbModel
// Konstruktor przypisujący ID przekazanego w parametrach użytkownika do modelu gracza.
// Wywoływany jest domyślny konstruktor.
public CharacterDbModel(
ApplicationUser user
) : this()
{
if (user != null) UserID = user.Id;
else UserID = null;
}
开发者ID:Hedonista,项目名称:RPGonline,代码行数:9,代码来源:CharacterModel.cs
示例4: CreateUser_Click
protected void CreateUser_Click(object sender, EventArgs e)
{
var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
var signInManager = Context.GetOwinContext().Get<ApplicationSignInManager>();
var user = new ApplicationUser() { UserName = Email.Text, Email = Email.Text };
IdentityResult result = manager.Create(user, Password.Text);
if (result.Succeeded)
{
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
//string code = manager.GenerateEmailConfirmationToken(user.Id);
//string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request);
//manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");
var myMessage = new SendGrid.SendGridMessage();
myMessage.AddTo(Email.Text);
myMessage.From = new MailAddress("[email protected]", "ToDoTaskList");
myMessage.Subject = "Welcome to ToDoTaskList!";
myMessage.Text = "ToDoTaskList is an iterative tasklist that helps you seize the day.";
var transportWeb = new SendGrid.Web("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");
transportWeb.DeliverAsync(myMessage);
signInManager.SignIn(user, isPersistent: false, rememberBrowser: false);
IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
}
else
{
ErrorMessage.Text = result.Errors.FirstOrDefault();
}
}
开发者ID:SIU-CS-435,项目名称:RARE-production,代码行数:29,代码来源:Register.aspx.cs
示例5: CreateAndLoginUser
private void CreateAndLoginUser()
{
if (!IsValid)
{
return;
}
var manager = new UserManager();
var user = new ApplicationUser() { UserName = userName.Text };
IdentityResult result = manager.Create(user);
if (result.Succeeded)
{
var loginInfo = Context.GetOwinContext().Authentication.GetExternalLoginInfo();
if (loginInfo == null)
{
Response.Redirect("~/Account/Login");
return;
}
result = manager.AddLogin(user.Id, loginInfo.Login);
if (result.Succeeded)
{
IdentityHelper.SignIn(manager, user, isPersistent: false);
IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
return;
}
}
AddErrors(result);
}
开发者ID:JohnnyEnc,项目名称:LoQueHay,代码行数:27,代码来源:RegisterExternalLogin.aspx.cs
示例6: CreateUser_Click
protected void CreateUser_Click(object sender, EventArgs e)
{
var manager = new UserManager();
var user = new ApplicationUser() { UserName = UserName.Text };
IdentityResult result = manager.Create(user, Password.Text);
if (result.Succeeded)
{
IdentityHelper.SignIn(manager, user, isPersistent: false);
IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
}
else
{
ErrorMessage.Text = result.Errors.FirstOrDefault();
}
}
开发者ID:JohnnyEnc,项目名称:LoQueHay,代码行数:15,代码来源:Register.aspx.cs
示例7: Register
public async Task<ActionResult> Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var user = new ApplicationUser() { UserName = model.UserName };
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
await SignInAsync(user, isPersistent: false);
return RedirectToAction("Index", "Home");
}
else
{
AddErrors(result);
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
开发者ID:GProulx,项目名称:side-waffle,代码行数:20,代码来源:AccountController.cs
示例8: CreateUser_Click
protected void CreateUser_Click(object sender, EventArgs e)
{
var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
var user = new ApplicationUser() { UserName = Email.Text, Email = Email.Text };
IdentityResult result = manager.Create(user, Password.Text);
if (result.Succeeded)
{
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
//string code = manager.GenerateEmailConfirmationToken(user.Id);
//string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request);
//manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");
IdentityHelper.SignIn(manager, user, isPersistent: false);
IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
}
else
{
ErrorMessage.Text = result.Errors.FirstOrDefault();
}
}
开发者ID:sotruser,项目名称:Testrepo,代码行数:20,代码来源:Register.aspx.cs
示例9: CreateUser_Click
protected void CreateUser_Click(object sender, EventArgs e)
{
var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
var signInManager = Context.GetOwinContext().Get<ApplicationSignInManager>();
var user = new ApplicationUser() { UserName = Email.Text, Email = Email.Text };
IdentityResult result = manager.Create(user, Password.Text);
if (result.Succeeded)
{
// Дополнительные сведения о том, как включить подтверждение учетной записи и сброс пароля, см. по адресу: http://go.microsoft.com/fwlink/?LinkID=320771
//string code = manager.GenerateEmailConfirmationToken(user.Id);
//string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request);
//manager.SendEmail(user.Id, "Подтверждение учетной записи", "Подтвердите вашу учетную запись, щелкнув <a href=\"" + callbackUrl + "\">здесь</a>.");
signInManager.SignIn( user, isPersistent: false, rememberBrowser: false);
IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
}
else
{
ErrorMessage.Text = result.Errors.FirstOrDefault();
}
}
开发者ID:zaharov-94,项目名称:publicHello,代码行数:21,代码来源:Register.aspx.cs
示例10: CreateUser_Click
protected void CreateUser_Click(object sender, EventArgs e)
{
var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
var signInManager = Context.GetOwinContext().Get<ApplicationSignInManager>();
var user = new ApplicationUser() { UserName = Email.Text, Email = Email.Text };
IdentityResult result = manager.Create(user, Password.Text);
if (result.Succeeded)
{
// 有关如何启用帐户确认和密码重置的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=320771
//string code = manager.GenerateEmailConfirmationToken(user.Id);
//string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request);
//manager.SendEmail(user.Id, "确认你的帐户", "请通过单击 <a href=\"" + callbackUrl + "\">此处 </a> 来确认你的帐户。");
signInManager.SignIn( user, isPersistent: false, rememberBrowser: false);
IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
}
else
{
ErrorMessage.Text = result.Errors.FirstOrDefault();
}
}
开发者ID:jieaido,项目名称:-,代码行数:21,代码来源:Register.aspx.cs
示例11: User
// Konstruktor tworzący kompletny model użykownika do wykorzystania na stronie (jeżeli zadziała).
//
// todo: Powyższy konstruktor może zwrócić wartość null w parametrze. Powoduje to NullReferenceException.
// Obecne rozwiązanie nie gwarantuje bezproblemowej obsługi wyjątków.
/// <summary>Tworzy nowy model użytkownika gotowy do wykorzystania na stronie</summary>
/// <param name="user">Użytkownik</param>
public User(
ApplicationUser user
)
{
try
{
Id = user.Id;
Email = user.Email;
PhoneNumber = user.PhoneNumber;
UserName = user.UserName;
UserSecureID = user.UserSecureID;
Status = user.Status;
Banned = user.Banned;
AvatarSrc = user.AvatarSrc;
Friends = GetFriends(Id);
}
catch(NullReferenceException exception)
{
throw exception;
}
}
开发者ID:Hedonista,项目名称:RPGonline,代码行数:27,代码来源:UserModel.cs
示例12: CreateUser_Click
protected void CreateUser_Click(object sender, EventArgs e)
{
var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
var signInManager = Context.GetOwinContext().Get<ApplicationSignInManager>();
var user = new ApplicationUser() { UserName = UserName.Text, Email = Email.Text };
IdentityResult result = manager.Create(user, Password.Text);
try
{
SqlConnection MyConnection = new SqlConnection("Data Source=cpeake.asuscomm.com;Integrated Security=False;User ID=matthew;Password=matthew;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False; Initial Catalog=WhenIf_Data;");
string sql = "UPDATE [dbo].[AspNetUsers] SET DEPAULID = @DEPAULID WHERE USERNAME = @USERNAME";
MyConnection.Open();
SqlCommand cmd = new SqlCommand(sql, MyConnection);
cmd.Parameters.Add("@DEPAULID", System.Data.SqlDbType.VarChar);
cmd.Parameters.Add("@USERNAME", System.Data.SqlDbType.VarChar);
cmd.Parameters["@DEPAULID"].Value = DepaulId.Text;
cmd.Parameters["@USERNAME"].Value = UserName.Text;
cmd.ExecuteNonQuery();
} catch (Exception exception) {
ErrorMessage.Text = exception.ToString();
}
if (result.Succeeded)
{
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
//string code = manager.GenerateEmailConfirmationToken(user.Id);
//string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request);
//manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");
signInManager.SignIn( user, isPersistent: false, rememberBrowser: false);
IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
}
else
{
ErrorMessage.Text = result.Errors.FirstOrDefault();
}
}
开发者ID:AkumaYouji,项目名称:WhenIfApp,代码行数:40,代码来源:Register.aspx.cs
示例13: CreateUser_Click
protected void CreateUser_Click(object sender, EventArgs e)
{
var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
var user = new ApplicationUser() { UserName = Email.Text,FirstName=FirstName.Text,LastName=LastName.Text, Email = Email.Text,City=City.Text,Street=Street.Text,ZipCode= Int32.Parse(ZipCode.Text),PhoneNumber=PhoneNumber.Text};
IdentityResult result = manager.Create(user, Password.Text);
if (result.Succeeded)
{
manager.AddToRole(user.Id, "NotConfirmed");
IdentityHelper.SignIn(manager, user, isPersistent: false);
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
string code = manager.GenerateEmailConfirmationToken(user.Id);
string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id);
manager.SendEmail(user.Id, "Scifiknihovna.cz - potvrzení registrace", "Prosím potvrďte svůj účet kliknutím na http://www.scifiknihovna.cz" + callbackUrl);
IdentityHelper.RedirectToReturnUrl("~/Account/RegisterSuccess.aspx", Response);
}
else
{
ErrorMessage.Text = result.Errors.FirstOrDefault();
}
}
开发者ID:honzabilek4,项目名称:WebApplication1,代码行数:24,代码来源:Register.aspx.cs
示例14: ExternalLoginConfirmation
public async Task<IActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl = null)
{
if (User.IsSignedIn())
{
return RedirectToAction(nameof(ManageController.Index),"Manage");
}
if (ModelState.IsValid)
{
// Get the information about the user from the external login provider
var info = await _signInManager.GetExternalLoginInfoAsync();
if (info == null)
{
return View("ExternalLoginFailure");
}
var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
var result = await _userManager.CreateAsync(user);
if (result.Succeeded)
{
result = await _userManager.AddLoginAsync(user, info);
if (result.Succeeded)
{
await _signInManager.SignInAsync(user, isPersistent: false);
return RedirectToLocal(returnUrl);
}
}
AddErrors(result);
}
ViewData["ReturnUrl"] = returnUrl;
return View(model);
}
开发者ID:cveld,项目名称:AsyncAwait-TypeScript-Example,代码行数:32,代码来源:AccountController.cs
示例15: Register
public async Task<IActionResult> Register(RegisterViewModel model)
{
EnsureDatabaseCreated(_applicationDbContext);
if (ModelState.IsValid)
{
var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
var result = await _userManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=532713
// Send an email with this link
//var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
//var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Context.Request.Scheme);
//await _emailSender.SendEmailAsync(model.Email, "Confirm your account",
// "Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>");
await _signInManager.SignInAsync(user, isPersistent: false);
return RedirectToAction(nameof(HomeController.Index), "Home");
}
AddErrors(result);
}
// If we got this far, something failed, redisplay form
return View(model);
}
开发者ID:cveld,项目名称:AsyncAwait-TypeScript-Example,代码行数:24,代码来源:AccountController.cs
示例16: ExternalLoginConfirmation
public async Task<ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl)
{
if (User.Identity.IsAuthenticated)
{
return RedirectToAction("Index", "Manage");
}
if (ModelState.IsValid)
{
// Get the information about the user from the external login provider
var info = await AuthenticationManager.GetExternalLoginInfoAsync();
if (info == null)
{
return View("ExternalLoginFailure");
}
var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
var result = await UserManager.CreateAsync(user);
if (result.Succeeded)
{
result = await UserManager.AddLoginAsync(user.Id, info.Login);
if (result.Succeeded)
{
await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
return RedirectToLocal(returnUrl);
}
}
AddErrors(result);
}
ViewBag.ReturnUrl = returnUrl;
return View(model);
}
开发者ID:tinadlj,项目名称:CSS-Style,代码行数:32,代码来源:AccountController.cs
示例17: Register
public async Task<ActionResult> Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
// Send an email with this link
// string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
// var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
// await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
return RedirectToAction("Index", "Home");
}
AddErrors(result);
}
// If we got this far, something failed, redisplay form
return View(model);
}
开发者ID:tinadlj,项目名称:CSS-Style,代码行数:24,代码来源:AccountController.cs
示例18: Update
public async Task<ActionResult> Update(RegisterViewModel model)
{
var SavedUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());
try
{
ApplicationUser UpdatedUser = new ApplicationUser();
UpdatedUser.SecurityStamp = SavedUser.SecurityStamp;
UpdatedUser.PasswordHash = SavedUser.PasswordHash;
UpdatedUser.UserName = SavedUser.UserName;
UpdatedUser.Id = SavedUser.Id;
ApplicationDbContext db = new ApplicationDbContext();
db.Entry(UpdatedUser).State = EntityState.Modified;
await db.SaveChangesAsync();
// var result = await UserManager.UpdateAsync(SavedUser);
return RedirectToAction("Index", "Home");
}
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
{
Exception raise = dbEx;
foreach (var validationErrors in dbEx.EntityValidationErrors)
{
foreach (var validationError in validationErrors.ValidationErrors)
{
string message = string.Format("{0}:{1}",
validationErrors.Entry.Entity.ToString(),
validationError.ErrorMessage);
// raise a new exception nesting
// the current instance as InnerException
raise = new InvalidOperationException(message, raise);
}
}
throw raise;
}
}
开发者ID:malcomvetter,项目名称:WidgetSender,代码行数:37,代码来源:AccountController.cs
示例19: SignInAsync
private async Task SignInAsync(ApplicationUser user, bool isPersistent)
{
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
///Open Question- Hear it create claimIdentity. But we nothing add as such Claims but just User object.
//public virtual Task<ClaimsIdentity> CreateIdentityAsync(TUser user, string authenticationType);
var identity = await UserManager1.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
//var identity = await UserManager1.CreateAsync(user);//, DefaultAuthenticationTypes.ApplicationCookie);
AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
}
开发者ID:AlexKrainov,项目名称:TourForEverybuddy,代码行数:12,代码来源:AccountController.cs
示例20: Register
public async Task<ActionResult> Register(RegisterViewModel model)
{
OglasController aleksaoglas = new OglasController();
if (ModelState.IsValid)
{
var user = new ApplicationUser() { UserName = model.UserName };
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
await SignInAsync(user, isPersistent: false);
var korisnik = new Korisnik() { IDKorisnik = user.Id, eMail = user.UserName, MailStize = 0 };
aleksaoglas.baza.Korisnik.Add(korisnik);
aleksaoglas.baza.SaveChanges();
return RedirectToAction("Login", "Account");
}
else
{
AddErrors(result);
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
开发者ID:aleksa93,项目名称:milos,代码行数:30,代码来源:AccountController.cs
注:本文中的WebApplication1.Models.ApplicationUser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论