httpcontext.current.session in legacy application to azure web apps

Divyasiri Edula 41 Reputation points
2020-06-26T14:00:08.703+00:00

Hi Team,

I have a Legacy asp.net web application which uses HttpContext.Current.Application[HttpContext.Current.Session.SessionID + "XYZ"] to store some objects like dictionary between class files.

Now we are planning to migrate Legacy application to Azure web apps. Can the session will be retrieved without changing the code in my application.

I know that there is azure Redis cache , but i do not want to change my code.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,872 questions
{count} votes

2 answers

Sort by: Most helpful
  1. ajkuma 22,401 Reputation points Microsoft Employee
    2020-06-29T16:48:26.177+00:00

    @DivyasiriEdula-7672, Apologies for the delay! This is a good question.

    Yes, Redis Cache would be better option. The code changes for moving Asp.net apps to Redis are quite minimal. Just to clarify, are you not intending to use Redis cache? Could you please share more about your requirement.
    If you were to leverage - HttpContext.Current.Session will be directly mapped to the Redis cache if the configuration is correctly completed as outlined in the documentation. There should be no other required code changes with one caveat: ‘Data stored in the cache must be serializable, unlike the data that can be stored in the default in-memory ASP.NET Session State Provider. When the Session State Provider for Redis is used, be sure that the data types that are being stored in session state are serializable’.

    Kindly let us know if you have more question, we would be more than happy to assist you.


  2. Nomvelo Zakwe 1 Reputation point
    2022-03-30T09:04:16.693+00:00

    Accept answer

    0 comments No comments