How to handle session management on cloud hosting in asp.net webform based website

752 views Asked by At

Let us say i have a website developed in asp.net webforms on .net 4.0 frame work and this needs to be migrated to cloud hosting like rackhosting.

This website currently uses asp.net default membership for user management and also uses several session variables for storing temporary variables.

This website is hosted on a dedicated server hosted inhouse.

so my question is

  • How to make it work on cloud hosting
  • One way of doing could be using MS Sql Server based session management
  • What else i need to take into consideration to make it work on cloud hosting

I have no experience with cloud hosting as one gets confused with the cloud hosting architecture provided by service providers. Microsoft Azure, Amazon etc..

any pointer to a good article and code examples would be great to start with

2

There are 2 answers

0
Mark On

You will need to use a Session State Provider that will span the servers. e.g. one that uses App Fabric (or other caching provider) or Sql Server

0
Liviu Costea On

For sharing sessions you have 2 options:
1. Sticky sessions, easiest to implement because there are no changes to do in code, but you will not be able to autoscale (add or reduce the number of machines based on load). This will be just a setting on your load balancer, so you need to check if the load balancer of your cloud provider has this.

2. Out of proc session and here I suggest to use the ASP.NET Redis session provider (supported by Microsoft). Both AWS and Azure provide Redis as a servce, so it is easy to start with, you don't need to think of its administration. Most important out of proc will mean some code changes, at least marking your classes that go in session as Serilizable, but you will be able to autoscale.