.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Session/Cache/Others in ASP.Net MVC application

Posted By:      Posted Date: October 21, 2010    Points: 0   Category :ASP.Net


We are developing an application which has tabbed views for user input. We need to "cache" the data entered in one tab while the user is filling up other tab. Though "Form Caching" is not allowed.

Please let me know the following:

  1. What is the best way of temporarily storing data in ASP.Net MVC web application?
  2. Are sessions a good idea?
  3. Are OutputCache and ResultCache the forbidden "Form Cache"? 



View Complete Post

More Related Resource Links

Session and Application Variables


I have a web application in which i need to logout the user if he clicks the logout button or even if he closes his browser window. On Logout button click, i am doing session.Abandon(), but how to go about his browser window close.

Can anybody help with a code sample.

Session between 2 website under 1 IIS application

Hi Please help me,i have 2 web application that resides in 1 IIS7 application via Virtual Directory, i hope to connect the 2 website via Session, my question is can i pass a session value from website 1 to website 2?thnx

Client Application Services - Role service cache time out bug

Hi All, For people using Client Application Services with WPF, be aware of this bug. You can configure the "cache time out" for roles to be fetched again from the service. (In the visual studio dialog, Properties -> Services -> Advanced) This means the roles are cached on the client (in a file). If the application asks for roles again, they are not fetched again for "cache time out" time. When you set this value, it goes into your App.config, transformed into seconds. So if you choose 1 minute, the App.config has: cacheTimeout="60".   However, when using the ClientRoleProvider (for instance to do something like clientRoleProvider.GetRolesForUser("SomeUser")), this cacheTimeOut is interpreted in Minutes, not seconds! To prove my point, check ClientRoleProvider.Initialize method:   string temp = config["cacheTimeout"]; if (!string.IsNullOrEmpty(temp)) _CacheTimeout = int.Parse(temp, CultureInfo.InvariantCulture);   Later on, in ClientRoleProvider.GetRolesFromDBUser (what's in a name?), you see: _CacheExpiryDate = cd.RolesCachedDateUtc.AddMinutes(_CacheTimeout);   Testing also shows this behavior. So be aware, and always put the value in minutes in your App.Config!   Regards, Koen

Cache settings on shared application pool

I have several web applications on a server using the same application pool. The worker process usually takes a lot of ram but usually only from one application. I can successfully limit the cache usage by setting "PrivateBytesLimit" in web.config file when the application uses it own dedicated application pool. Does anyone know how this setting will be applied when using shared application pool? Is it per application, per worker process or per application pool? Also if it is not per application which setting from which application will be applied?

Access HttpApplication cache from different application/domain

Hello all, How can I access the cache of one web application/domain from another web application/domain? Here is my scenario. I need to verify/check the existence of a certain object in one web application/domain's cache from another web application/domain. Any guidance on how to do this? Thanks.  - Randolph

What's the best way to store Data from DataBase like XmlNode... Application vs Cache


 Hello, i am building an N-tier application now i want to store Data(like XmlNode) that is common to all users ..

now i thought using Application to hold the data but my data lays in the BLL tier which is an Class Library project and i can't store any datain there for example :

HttpApplication MyApp=new HttpApplication();



My question is what is the best way to store Data (not small data like user name etc..) is it Application? orCache?

i would like a small example within a ClassLibrary project...




User Interface: 2 Labels;  1 Buttons

Requirements: Create a Web Page in ASPx that will do the following:


1)      One label will provide a count of how many times Button 1 has been clicked in the current session.

2)      One label will provide a count of how many times Button 1 has been clicked by all users of the application.

          The Application Code for the Button should start at 100 (set this in the Global.asax file).


this is what i have so far but i cant seem to get the application state to work properly.


Partial Class _Default
    Inherits System.Web.UI.Page
    Dim clickcount As Integer

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Session("ClickCount") Is Nothing Then
            clickcount = 0
            clickcount = CInt(Session("ClickCount"))
        End If

Is embedding of fonts in wpf application will save from corrupted font cache?



Recently I had corrupted font cache. I fixed it by removal of cache file and restarting of Wpf font cache service. Also I updated my outdated driver.

However there're lot's of users on customer side without administrative rights and there're no way to upgrade their pretty old drivers of videocards.


Could you say me what if i embed all fonts application use in application resources - will it help those guys to not relay on Font Cache ?

How to get current user session in Windows application C#?



I am trying to create a Windows Application similar to facebook friend finder.exe in .NET. The steps I have followed to achieve this is as follows:

1. I have created a webservice containing webmethod SaveContacts(string firstname, string lastname, string number, string photo, string email, string userid).


2. I am consuming the webservice in a Windows Form application and calling the above mentioned function.

Now, I want to get the current logged in user ID which through the windows form application which is something tedious to me.

If anyone have any idea how to achieve this. Please help.






session variable and multiple web application instance


 I have a web application using window authentication. There are a search page and a edit page in the application. 

In search page, user can enter some search criterias in the textboxes and the search result will be displayed in the gridview by clicking the "Search" button. User can select any row from the gridview and it will take him to the edit page. 

 In the edit page, there is a "Back" button to take the user back to the search page. I use session variables to remember what the search criterias the user entered in the textboxes and what page number the user was in the gridview. So when the user goes back to the search page, the textboxes are pre-populated with the search criterias and the gridview is displayed in the correct page number.

The problem is:

If user1 opened one browser window and did a search using search criterias1, then user1 opened a 2nd browser window and did a search using search criterias2. When the user1 went back to the search page from the edit page using the first browser window, all the textboxes and page numbers are from the 2nd browser window, instead of the 1st one.

Can anyone explain this problem to me and how to prevent it? It will be helpful too if you can give me some links about the similar problem.

ASP.NET 4.0 Store Cache and Session on Disk


1) Can someone please point me to an example of ASP.NET to store cached pages and session on hard disk.

2) Also, I never tried this but is it possible to save Application variables to disk?

Maintain WCF Session with .NETCF 2.0 Mobile Application


I am developing Windows Mobile Application (NETCF 2.0) which needs to make connection to WCF Service (4.0) hosted on IIS. Mobile Application establishes connection with Server (containing WCF Service) for each transaction which requires authentication from database.

How can I maintain WCF Sessions to authenticate Mobile Application for the first time (using database credentials) and store/use that Session to serve subsequent requests coming from Mobile Application?

My Mobile Application uses NETCF 2.0 and WCF uses 4.0.

Application or Cache?



I'm saving some tiny variables (such as a visitor counter)  to Application("myvariable"). It works fine on my testing machine.

Now I read that one should use Cache("myvariable") instead, as Application could be a bottleneck (I need to update the variable in a .ascx page, and someone said it should be done in the Global page).

Is ths correct, or can I live happily with my Application variables? I'd prefer not to change it, as I really want these variables to live as long as the application lives or until they are reset in code.

Thanks a lot for clarifying!


how to maintain session for multi user application


I am developing a web application. This application is fully customised based on the user settings. Suppose, application hosted on www.abc.com and user can signup on the website and it will get the domain like www.user1.abc.com and for user2 will be www.user2.abc.com so and so forth. so in this case how would I maintain the session for each user?

each user will be representing a single website along with public interface and admin pages. 

what I am thinking is to store all the setting (for each user) in the database and then when ever server received request then get the user info from the URL (first time only and after get it from the session) and get user details but I am not very much satisfied with this approach. 

could anyone recommend me any better way to perform this task please? 


Session Timeout in WPF browser application


Hi All,

I have to design a web browser application in WPF with a session timeout facility. The requirement to provide a session timeout after 1 hours. How can this be achieved? Also i need to implement login based menu access levels in this application. How can i achieve both these?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend