Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does asp.net MVC have Application variables?

I am busy converting a web application to MVC and have some information saved to Application variables used across multiple tenants/accounts to make things a bit more efficient.

I realise the point of MVC is to keep things as stateless as possible, Sesion State obviously makes sense to have and exists in MVC but we dont want to just convert Application to Session variables as we would rather have something more global and more secure. Do MVC applications have Application Variables? I have seen some examples where caching is used? Is this now standard and How robust/secure is this compared to Application/Session State?

like image 516
Mark Redman Avatar asked Feb 15 '10 14:02

Mark Redman


People also ask

How can use application variable in ASP NET MVC?

Application State variables are like multi-user Global data. Application variables are stored on a web server. Application State variables are cleared, only when the process hosting the application is restarted, that is when the application is ended.

What are application variables in asp net?

Application variables are values that are available to any user or page within an application. For the first time, they can be any value you wish to store.

What are the 3 main components of an ASP NET MVC application?

The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller. The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating MVC-based Web applications.

What is application variable in asp net c#?

Application variables are the variables which remain common for the whole application for all the users… Their value can be used across the whole application by any user… And they die only when the application stops or probably when they are killed forcibly…


1 Answers

Yes, you can access Application variables from .NET MVC. Here's how:

System.Web.HttpContext.Current.Application.Lock(); System.Web.HttpContext.Current.Application["Name"] = "Value"; System.Web.HttpContext.Current.Application.UnLock(); 
like image 50
WWC Avatar answered Sep 28 '22 00:09

WWC