0

I have a problem losing the session state in my asp.net application, maybe u can help me.

First of all, I'm using asp.net and js as visual presentation, then I used web services to enable the conection with my database class. When I start the application I store the session (SqlServer mode) usgin the next method:

public static string User{
get{
   try{
      return (HttpContext.Current.Session != null && HttpContext.Current.Session["User"] == null) ? "" : (string)HttpContext.Current.Session["User"];
      }
   catch (Exception e){
      string white = "";
      string msg = e.Message;
      return white;
   }
}
set{
   HttpContext.Current.Session["User"] = value;
}

}

Then, when I need to use the session I make the next call:

string nomUsuario = ses.getUser();

It works perfectly until I try to reach the session since a pop-up window. For example, in my codification I call a new window using js:

$("#states").modal("show");
var transporte = function () {
    $('a.viewTransport').live('click', function () {
    .....
}

When I debbug my aplication I can see that the result is "HttpContext.Current.Session = null" when I'm inside the pop-up window.

My webconfig:

<sessionState mode="SQLServer" timeout="40" allowCustomSqlDatabase="true" sqlConnectionString="Data Source=localhost\SQLEXPRESS;Integrated Security=SSPI;" cookieless="false" />

Thanks for the Help

Bellninita
  • 13
  • 3
  • What is inside the popup window? If you're using the bootstrap modal component then this should be just showing content that is already on the page, of which it should be any different than other parts of the page. Are you showing an iframe within the modal by any chance? – Mark Fitzpatrick Sep 25 '14 at 23:21
  • Is your session getting saved to SQL Server properly? And, get your session using Session["User"] rather than HttpContext.Current.Session["User"]. Because there's a slight difference some times according to this SO thread http://stackoverflow.com/questions/940742/difference-between-session-and-httpcontext-current-session – Sam Sep 25 '14 at 23:33
  • Where are you accessing SessionState which end up with null? Where is `public static string User` located? – Win Sep 26 '14 at 00:15

0 Answers0