How to handle the Session from ASP to MVC2? RRS feed

  • Question

  • User-591036209 posted

    We are facing some issue in handling the Session from ASP to MVC2.
    All the sessionstates are stored in SQL server and Scenario like Main application in Classic ASP and when i use ASP.net we are able handle the session(system.web) in client application but when i migrate/move to MVC2.0(it supports Dotnet Framwork3.5) not able to handle session(system.web.mvc).Could you please guide us how to do that?

    Tuesday, January 29, 2019 5:00 PM

All replies

  • User753101303 posted


    Unclear. My understanding is that you moved an ASP Classic application to ASP.NET but have some problem when trying to add MVC 2. You should not as MVC is just a part of "ASP.NET". Or do you mean that you are trying to share session values between ASP classic and ASP.NET ?

    Also 3.5 and MVC 2 is quite outdated already. I would use at least 4.5.2 and MVC 5 for a new app or an upgrade.

    Tuesday, January 29, 2019 5:13 PM
  • User-591036209 posted

    Basically i want to know, How to share a ASP session into MVC 2.0?

    Wednesday, January 30, 2019 4:54 AM
  • User753101303 posted

    So in ASP Classic you are not using the session state but rather your own session state like calls ? The easiest approach would be likely to just do the same in ASP.NET especially if the ASP classic part will be retired soon. You'll just use your own custom calls to store/retrieve "session" values.

    As many other parts in ASP.NET the session state mechanism is replaceable. Though you have a SQL Server based provider, another option could be to use https://docs.microsoft.com/en-us/previous-versions/aspnet/ms178587(v=vs.100) and write a custom provider which is compatible with your existing ASP Classic implementation (but it is likely significantly more complex than option #1 and you'll likely throw this once the migration is fully done).

    Else try to be more specific. In particular it seems you are telling that it works across ASP and ASP.NET but not with MVC (it shouldn't be a problem as MVC is part of ASP.NET and uses the same session state mechanism). So I'm still not 100% sure about the exact problem you have.

    Wednesday, January 30, 2019 8:01 AM
  • User-2054057000 posted

    Basically i want to know, How to share a ASP session into MVC 2.0?

    Go to the web.config file of MVC application and set the connection string for the session. The connection string should be for your sql server where sessions are stored.

    Friday, February 1, 2019 5:44 PM
  • User-1038772411 posted

    I did it this way:

    Basically the idea is both apps use native .net sessionState stored in sqlserver. By using the same machine key and making a small tweak to a stored procedure – both apps can share any session keys and/or forms authenication.

    Both apps would do something like this in their web.config:

    <sessionState mode="SQLServer" sqlConnectionString="Data Source=.\SQLEXPRESS;User Id=test;Password=test;Application Name=AppName"  />
    validation="SHA1" decryption="AES"

    You Can use session for all .net version independently. hope its also work fine for you. 

    Wednesday, March 13, 2019 10:28 AM