How do I put the usermanager property to be started in my Model

1

I would like the form Name to be filled in automatically by the username of the logged in user.

How do I include this property in my 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; }  
     }
   }
    
asked by anonymous 16.05.2017 / 23:38

2 answers

1

In Controller :

var condominio = new Condominio { Nome = User.Identity.Name };
return View(condominio);
    
16.05.2017 / 23:47
1
 public string Nome{
  get{
      if (HttpContext.Current.Session["usuario"] != null)
             return  HttpContext.Current.Session["usuario"];
   }

}
    
16.05.2017 / 23:55