1
I have the code below, and to call the Session that stores the user data, only once I want to put it in the controller statement.
Doubt
The variable usuarioLogado
is by request or it may happen that user X calls the controller and in between user Y calls the same controller, and usuarioLogado
information exchange, where should be reading user X, step to have user Y.
Code
public class AppRequisitoController : Controller
{
string controller = "AppRequisito";
UsuarioLogadoDTO usuarioLogado = Services.UsuarioService.SessaoUsuarioLogado();
private void Listagem(Conexao db)
{
var repAppRequisito = new AppRequisitoRepositorio(db);
ViewBag.ListaAppRequisito = repAppRequisito.ComboBox(usuarioLogado);
}
User Session
public static UsuarioLogadoDTO SessaoUsuarioLogado()
{
return HttpContext.Current.Session[Constantes.sessaoUsuarioLogado] as UsuarioLogadoDTO;
}
What does
Services.UsuarioService.SessaoUsuarioLogado();
?– Leonel Sanches da Silva
@I edited the question.
– Tiedt Tech
I don’t think it’s a good idea for you to wear
Session
to get the user logged in. Better use authentication provider information.Session
is not consistent 100% of the time in application without states like those written in ASP.NET MVC. This code will stop working quite frequently.– Leonel Sanches da Silva
@Ciganomorrisonmendez would have some example of authentication provider?
– Tiedt Tech
Membership, Identity... I don’t know what you’re wearing.
– Leonel Sanches da Silva
@Gypsy I’m using Membership
– Tiedt Tech