---
title: "What is the difference between SessionState and ViewState in ASP.NET?"  
description: "What is the difference between SessionState and ViewState in ASP.NET?"  
author: "Vijay Shukla"  
published: 2012-12-15  
updated: 2020-09-24  
canonical: https://www.mindstick.com/interview/1604/what-is-the-difference-between-sessionstate-and-viewstate-in-asp-dot-net  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# What is the difference between SessionState and ViewState in ASP.NET?

## SessionState

- Can be persisted in memory, which makes it a fast solution. Which means state cannot be shared in the Web Farm/Web Garden.
- Can be persisted in a Database, useful for Web Farms / Web Gardens.
- Is Cleared when the session dies - usually after 20min of inactivity.

## ViewState

- Is sent back and forth between the server and client, taking up bandwidth.
- Has no expiration date.
- Is useful in a Web Farm / Web Garden

## Answers

### Answer by Vijay Shukla

## SessionState

- Can be persisted in memory, which makes it a fast solution. Which means state cannot be shared in the Web Farm/Web Garden.
- Can be persisted in a Database, useful for Web Farms / Web Gardens.
- Is Cleared when the session dies - usually after 20min of inactivity.

## ViewState

- Is sent back and forth between the server and client, taking up bandwidth.
- Has no expiration date.
- Is useful in a Web Farm / Web Garden


---

Original Source: https://www.mindstick.com/interview/1604/what-is-the-difference-between-sessionstate-and-viewstate-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
