Monday, October 28, 2013

QueryString Vs Session

  1. Query string parameters
    Pros:
    • Very simple to see what values are being passed.
    • Built-in .NET capability.
    • Useful for bookmark or favorites functionality in an application, because the page can be loaded up using the query string value; not dependent upon data being in a certain state in the application.
    Cons:
    • Each browser has a theoretical limit with Internet Explorer being the smallest at 2,048 characters.
    • Passing representation of objects is not possible with query strings (i.e. a list of Customer class objects).
    • Represents a potential security risk in that values are exposed. DO NOT pass any sensitive information in a query string.
  2. In-process session state variables
    Pros:
    • Built-in .NET capability.
    • Allows for storage of large and complex objects, such as list of Customer objects.
    • Resides in memory so you do not need to remember to keep on passing the value between page navigation.
    Cons:
    • It is volatile as it is in memory, must keep checking to see if data is actually there or not.
    • Can significantly increase the memory usage of your application; this is an issue if you are not the only application on your server.