Fórum USO DE HttpContext.Current.Session numa Classe #27247
12/03/2010
0
Usando o Session numa pagina aspx funciona normalmente
A Session tem conteudo, já verifiquei fora da classe. O que está errado.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; /// <summary>
/// Summary description for Class1
/// </summary>
public class Class1
{
public string Retorno()
{
if (HttpContext.Current.Session["Content"] != null)
return (string)HttpContext.Current.Session["Content"];
else
return "";
}
}
Sidney Mendonça/
Curtir tópico
+ 0Posts
12/03/2010
Fabio Mans
Faça referência a Namespace abaixo.
using System.Web;
Espero ter ajudado.
Fabio
Gostei + 0
12/03/2010
Fabio Mans
public string Retorno()
{
if (HttpContext.Current.Session != null)
if (HttpContext.Current.Session["Content"] != null)
return (string)HttpContext.Current.Session["Content"];
else
return "";
return null;
}
Gostei + 0
12/03/2010
Fabio Mans
using System.Text;
using System.Web;
namespace GrupoSBF.Corporativo
{
public class EnvioEmail
{
public string Retorno()
{
if (HttpContext.Current.Session != null)
if (HttpContext.Current.Session["Content"] != null)
return (string)HttpContext.Current.Session["Content"];
else
return "";
return null;
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
Session["Content"] = "teste";
EnvioEmail obj = new EnvioEmail();
string teset = obj.Retorno();
}
Gostei + 0
15/03/2010
Fabio Mans
Gostei + 0
15/03/2010
Sidney Mendonça/
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)