0

I have problem with ASP.NET MVC5. It works well on Visual Studio 2013 update 2 but on production or test server 2008 or 2012 it is not.

I have simple thing to do. Deliver bunch of variables form one view to other. Naturally I use:

HttpContext.Session["Mailpack_ID"] = id;

Doesn't work on Windows Server (both iis 7.5&8 ). I use this solution: ASP.NET MVC - Session is null

Solution 1 - Don't work, so I write my own class witch can storage variables (avoid using session):

public class StorageSingleton
{
           private static StorageSingleton instance;
           private StorageSingleton() { }

           public static StorageSingleton Instance
           {
              get 
              {
                 if (instance == null)
                 {
                     instance = new StorageSingleton();
                 }
                 return instance;
              }
           }         
           public string Mailpack_ID { get; set; }            
}

Use in code:

var storage = StorageSingleton.Instance;
storage.Mailpack_ID = id.ToString();

It was surprise for me - but nothing. I think when I use class all information are in code, but I get the same error. I have any idea. Any help?

Community
  • 1
  • 1
  • Using **StorageSingleton** to substitute **SessionState** is not a good idea. Does **TempData** not work for your scenario? Is it running on Web Farm or Web Garden? – Win Oct 21 '14 at 16:51
  • 1
    @lukwieand Could you provide Web.config Session configuration section and MvcApplication class code? – yW0K5o Oct 21 '14 at 17:08
  • If something as key as SessionState isn't working, you have something seriously wrong with your configuration. Don't just ignore it and try crazy workarounds, fix the ACTUAL problem. Singletons in a multi-threaded/multi-user environment like a web application are bad. Very bad, since they are shared between all users. – Erik Funkenbusch Oct 21 '14 at 17:08
  • You say "I get the same error". Perhaps it might help if you actually said what the error is. Perhaps your actual problem is that id is actually null? – Erik Funkenbusch Oct 21 '14 at 17:11

0 Answers0