---
title: "static variable in asp.net"  
description: "static variable in asp.net"  
author: "Anonymous User"  
published: 2014-11-20  
updated: 2014-11-20  
canonical: https://www.mindstick.com/forum/12657/static-variable-in-asp-dot-net  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# static variable in asp.net

I would like to have kind of [static variable](https://www.mindstick.com/forum/34587/static-variable) but isolated for each [user](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) [session](https://www.mindstick.com/articles/12042/session-in-c-sharp) so is static variable in [asp.net](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) [common](https://www.mindstick.com/articles/23170/10-most-common-accounting-mistakes-of-small-business) to all [users](https://www.mindstick.com/news/2244/issue-preventing-users-from-accessing-facebook-s-social-networking-platforms-has-been-resolved) ?

[If yes](https://www.mindstick.com/forum/159589/can-we-crash-jvm-if-yes-then-how) is there an easy to emulate what I want without using user session explicitly ? I cannot use [Viewstate](https://www.mindstick.com/blog/326/viewstate-in-asp-dot-net) either as I'm using MVC (or am I mistaken ?)

## Replies

### Reply by Sumit Kesarwani

Hi Chintoo, \

A [static](https://www.mindstick.com/articles/12098/the-static-keyword-the-static-methods) [variable](https://www.mindstick.com/articles/1807/objective-c-data-types-variables-object-creation) will be common for all sessions yes.

If you want to keep per-user-session data you have three options:

· Use built in Session handling.

· Set a cookie.

· Pass the data as a hidden form field that is posted to the server (works for places where you have a form anyway).


---

Original Source: https://www.mindstick.com/forum/12657/static-variable-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
