locked
Instead using Session what could be other approach which should be compatible when release asp.net core application in Azure Cloud RRS feed

  • Question

  • User-1965208702 posted

    HI All,

    I have got the requirement to migrate our existing MVC application to asp.net core MVC application.

    In MVC application i used session to traverse the data from one controller to another, Now we have plan to move the application to Azure Cloud using Container Registry.

    Since i have started it from scratch, I need to use some other approach instead using Session, So In Cloud there should not found any issue when traverse the data.

    I need here your best suggestion, Instead using session what other approach should use to achieve the same.

    Kindly suggest.

    Tuesday, July 14, 2020 2:34 PM

All replies

  • User541108374 posted

    Hi,

    if you're going for Azure App Services (websites) you can set it up that a new request from a user goes back to the same server (assuming you have set up multiple in Azure of course for load balancing your application). So in the beginning you could keep on making use of session state.

    For Azure you could make use of azure storage, cosmosdb or azure cache for redis instead of session state (make a choice not only over tech but also cost!).

    On the other hand: why session state? A popular approach is setting up a SPA application with Web api in the background or setting up a SPA and making use of Azure Functions. Recently Azure jamstack was announced. The SPA doesn't have to be with JavaScript however as you could also check out Blazor (I'm currently creating such an application at my client).

    Kris

    Tuesday, July 14, 2020 3:59 PM
  • User-474980206 posted

    What’s wrong with session? Asp.net core uses a non-blocking async session. Could use redis, or azure sql. Could use table store, lots of options.

    Wednesday, July 15, 2020 2:06 AM
  • User-1965208702 posted

    Hi Bruce,

    Thank you for your suggestion. I just wanted to know few things about session which is below:

    1. Azure Container registry or Azure (PAAS) : accept session? Since i was using session to validate User authentication, Also to move data from one controller to another or Controller to view.
    2. If it not accept Session, Then can i use Token for user authentication and then for carry data, Can use TempData['Temp'] from controller to another.
    3. Or What could be your best approach in above case to implement?

    Thanks

    Wednesday, July 15, 2020 8:04 AM
  • User-1965208702 posted

    Hi All,

    Any update on above asked? Still waiting for your answer.

    Wednesday, July 22, 2020 12:34 PM
  • User753101303 posted

    Hi,

    Usually you can configure that (and it is enabled by default for Azure web sites, not sure for containers, you'll use AKS ?). Also I usually use session aonly for few frequently used short stuff that I can load again as needed so that I don't care about session expiration.

    Not sure about your design. You replaced an authentication cookie entirely with a session value or what is exactly the purpose of this value ? (rather an anti forgery token ?)

    Wednesday, July 22, 2020 12:53 PM
  • User-474980206 posted

    <div style="display: none;"></div>

    Hi Bruce,

    Thank you for your suggestion. I just wanted to know few things about session which is below:

    1. Azure Container registry or Azure (PAAS) : accept session? Since i was using session to validate User authentication, Also to move data from one controller to another or Controller to view.
    2. If it not accept Session, Then can i use Token for user authentication and then for carry data, Can use TempData['Temp'] from controller to another.
    3. Or What could be your best approach in above case to implement?

    Thanks

    session is just a library. you can include it in a docker image. you will need to add the code, and configuration.

    not sure what session has to do with user validation. session is for storing state between requests. its typically a persistent store, with the key stored in a cookie.

    the default implementation of TempData is to store the actual value in a cookie and not use a persistent store.

    again this is just code in the application, and does not depend on hosting services, other than support to write host headers (cookie) and access a data store. 

    Wednesday, July 22, 2020 4:05 PM