4
I have an acceptance problem. After configuring Microsoft.AspNet.WebPages.WebData
and the corresponding classes, the system correctly created the tables in the database so that I could implement the code for user registration, password and password confirmation. Well, the idea is to write to Webdata and my table normally, but when you run and debug it works until you get to the method WebSecurity.CreateUserAndAccount(model.Email, model.Senha.ToString())
.
debug informs you are login and password perfectly, but the error says not to add null password. Does anyone have any idea what is missing?
Thanks in advance. Below the image that proves the error and the configuration codes.
Configuration of the Webconfig:
<system.web>
<!-- Outras configurações -->
<membership defaultProvider="churrascadaProvider">
<providers>
<add name="churrascadaProvider"
type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData"/>
</providers>
</membership>
</system.web
<appSettings>
<!-- Outras configurações -->
<add key="loginUrl" value="~/Conta"/>
</appSettings>
Within Global.asax application start:
WebSecurity.InitializeDatabaseConnection("ChurrascadaContext", "Contas", "IdConta", "Email", true);
Controller Code:
// POST: Conta/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(ContaModel model)
{
if (ModelState.IsValid)
{
try
{
WebSecurity.CreateUserAndAccount(model.Email, model.Senha.ToString());
//Buscando o Id da Conta no banco e inserindo no objeto conta
Conta conta = new Conta();
conta.IdConta = contasDAO.BuscaPorEmail(conta.Email).IdConta;
return RedirectToAction("Create", "Usuario", new {idConta = conta.IdConta });
}
catch(MembershipCreateUserException e)
{
ModelState.AddModelError("usuario.invalido", e.Message);
return View("Create", model);
}
}
else
{
return View("Create", model);
}
}
For you to need to give a Tostring() in your password in the controller, it is what type of variable?
– Striter Alfa