We help IT Professionals succeed at work.

Session variables vs. Application variables Question

I just had an inquiry regarding the use of Session variables versus using Application. In other words, an application I've taken over was written so that several domains point to the same application. Depending on the specific domain name, user controls were created to show different graphics.

In the global.asax file, there is a function which gets the Url and assigns it as in the snippet below. My question was, would using Session as opposed to Application be better/worse? What are the differences between the two, because I've tried it both ways and they both work for all intents and purposes.


void Application_BeginRequest(object sender, EventArgs e)
    {        
        Application["URL"] = Request.Url.ToString(); // some-domain.com or some-domain2.com
        //Session["URL"] = Request.Url.ToString(); // Or use this?
    }

Open in new window

Comment
Watch Question

Software Applications Developer / Integrator
CERTIFIED EXPERT
Commented:
The session variables will be unique for each user.
the application variables will be shared and could cause a variable to be overwritten by a different user.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.