How do I get the usermanager property started in my Model

Asked

Viewed 63 times

1

I wanted to form the field Name is automatically filled in by the username you are logged in to.

How to include this property in mine Model?

     public class Condominio
     {


         public int CondominioId { get; set; }


         public string Nome { get; set; }

         public int CEP { get; set; }

         public string Endereco { get; set; }


         public int Numero { get; set; }  
     }
   }

2 answers

1

In Controller:

var condominio = new Condominio { Nome = User.Identity.Name };
return View(condominio);

1

 public string Nome{
  get{
      if (HttpContext.Current.Session["usuario"] != null)
             return  HttpContext.Current.Session["usuario"];
   }

}
  • Please collaborate with the quality of community content by better elaborating your response. Very short answers will hardly be clear enough to add anything to the discussion. If your response is based on some function or feature of the language/tool, link to the official documentation or reliable material that supports your response. Searching for similar questions in the community can also be interesting to indicate other approaches to the problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.