I am using ASP.NET Identity to control the authentications in my application, the possible validations with DataAnnotation I am already doing however all the validations are in the standard in English and I would like to be able to translate them. For example, in the code below, when I try to create a user and it already exists in the database, it returns the validation "Name xxxx is already taken." How can I proceed? I can override the CreateAsync method, but I do not know the behavior of the method.
I installed the packs pt-BR:
Microsoft.AspNet.Identity.Core.pt-br 2.2.1
Microsoft.AspNet.Mvc.pt-br 5.2.3
Microsoft.Owin.pt-br 3.1.0
I put globalization in webconfig and it did not work.
I am putting the controller code, to understand a little what I mean and the method I am using. On the occasion after creating the login, you are automatically logging into the application. Following:
private ApplicationSignInManager _signInManager;
private ApplicationUserManager _userManager;
.
.
.
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Registrar(RegistrarViewModel model)
{
if (ModelState.IsValid)
{
var user = new ApplicationUser { UserName = model.UserName };
var result = await _userManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
await _signInManager.SignInAsync(user, isPersistent: true, rememberBrowser: false);
return View("Login", "Account");
}
foreach (var error in result.Errors)
{
ModelState.AddModelError("", error);
}
}
return View(model);
}