Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 606685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:16:49+00:00 2026-05-13T17:16:49+00:00

Let’s say you’re building something simple, like a data entry/CRUD form for working on

  • 0

Let’s say you’re building something simple, like a data entry/CRUD form for working on an entity called Customer. Maybe you pass the CustomerID in via Session state.

I tend to write a lot of fairly boilerplate plumbing code around handling that Session variable in a particular way. The goals vary slightly but tend to be things like:

  • Avoid cluttering the main flow of the page with plumbing code
  • Handle the back button intelligently
  • Remove the variable from Session and persist it to ViewState ASAP
  • Code defensively for failure situations where the state doesn’t get passed, or is lost

Do you have a best practice for handling this situation? Do you have classes in your stack that handle this perfectly every time? Do you just call the Session variables directly? Do you use encrypted QueryString and avoid Session variables in this situation entirely in order to make the back button work a little better?

Lately I’ve been using Properties with Session variables. Here’s a simple example that I just threw together, although please keep in mind that this example would not be very tolerant of the back button:

Private ReadOnly Property CustomerID() As Integer
    Get
        If Me.ViewState(Constants.CustomerID) Is Nothing Then
            If Me.Session(Constants.CustomerID) Is Nothing Then
                Throw New ApplicationException("CustomerID was not persisted.")
            Else
                Me.ViewState(Constants.CustomerID) = Me.Session(Constants.CustomerID)
                Me.Session.Remove(Constants.CustomerID)
            End If
        End If

        Return Me.ViewState(Constants.CustomerID)
    End Get
End Property

So, how does your shop handle this? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:16:50+00:00Added an answer on May 13, 2026 at 5:16 pm

    Teams I have worked on do not pass this kind of workflow information around in session, primarily because of the difficulty it poses to web farms/gardens. We think of session as a container for information that is relevant most (if not all) of the time from the moment the user first hits the site to the moment they leave. Even then, I’d only use session if that information was very expensive to retrieve/build, and only if I knew that the load balancer would stick the user to a particular server in a farm or that we had a suitable out-of-process session provider in place.

    Instead I would pass this type of information via the query string, hidden input field, or ViewState (if enabled), and provide friendly error-handling when invalid values are sent. If history management is important, I would leverage ASP.NET AJAX history management.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I'm building a data access layer for an application. Typically I have
Let's say you have a class called Customer, which contains the following fields: UserName
Let's say I've got a collection of 10 million documents that look something like
Let's say we have this code: <form action='' method='POST' enctype='multipart/form-data'> <input type='file' name='userFile'><br> <input
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say I have a string like this: var str = /abcd/efgh/ijkl/xxx-1/xxx-2; How do
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I can call a method like this: core::get() . What is the
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
Let's say there is a graph and some set of functions like: create-node ::

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.