Application Versus Session / Cache
Feb 23, 2011What is an appropriate use case for all of the above? It seems session and cache are quite similar, and I can't think of much use for application.
View 3 RepliesWhat is an appropriate use case for all of the above? It seems session and cache are quite similar, and I can't think of much use for application.
View 3 RepliesIm building a image gallery which reads file from disk, create thumbnails on the fly and present them to the user. This works good, except the processing takes a bit time.
I then decided to cache the processed images using the ASP .NET Application Cache. When a image is processed I add the byte[] stream to the cache. As far as I know this is beeing saved into the system memory. And this is working perfect, the loading of the page is much faster.
My question is if there are thousands of images which gets cached in the Application Cache, will that affect the server performance in any way?
i've been coding an asp.net site using VS2005 for about one month.
my site uses both application cache and session cache to save data.
the syntax i use for application cache is :
HttpApplicationState appState = Application;
appState["someKey"] = "somevalue";
and for session cache i use :
HttpContext.Current.Session["someKey"] = "Somevalue";
my site is deployed on three standalone servers - each server runs a diffrent instance of the site.
two of the servers work just fine, the third has a stange problem - and also has the least free memory space.
in this server items start dissapearing from both the session and application cache - note that i set no expiration date to the cache items.
does anyone know why this could happen?
seems to me there is perhaps some memory limit for cached items setting that i am missing.
I have a SharePoint 2010 Farm and want to use object caching for my own custom objects.
Since it's an ASP.net Application at it's core, I could use HttpRuntime.Cache. On the other hand, SharePoint 2010 offers it's own SPCache.
Why would I choose SPCache over the HttpRuntime.Cache one?
What are the "optimal" parameters for creating an AppFabric cache when you will be storing session state in the cache? MSDN Cache-Related Commands
Powershell command line:
New-Cache [-CacheName] <String> [-Eviction <String>] [-Expirable <String>] [-Force [<SwitchParameter>]] [-NotificationsEnabled <String>] [-Secondaries <Int32>] [-TimeToLive <Int64>]
[code]...
Since I don't want my sessions to be removed unless the session has been abandoned either via code or Session Timeout...For eviction, I would think "None" and for expireable, I would think False.I have tested and calling Session.Abandon does remove the object from the cache. I have also tested to see if by extending my session, the session object in cache is also extended. This does seem to work the "correct" way.
Is there a difference between Session.Clear() and Session.RemoveAll()? The descriptions and documentation pages seem to say exactly the same thing, but I am assuming there must be some reason for creating two functions, right?
View 2 RepliesI have an application that goes through a series of questions and I have a view that shows each question based on the ViewData.
I would like to store the QuestionID (the view uses this to determine which question to show), but I'm curious if I should be storing the CurrentQuestionID in the Session or as a hidden field?
I am sure this is pretty common and I was curious what the conventions/best practices were for this sort of thing.
I'm working with an asp.net application that stores most data in a database and not session. I'm wondering of the pros and cons of each and which is the better way to go. For example, you have a pretty busy site and instead of storing user specific variables in session, there is a DB table called user data and it can store all user specific data that can be accessed from any page by querying the database. Which is the better way to go, session or database?
View 4 RepliesWhat is difference between Session.Clear() vs. Session.Contents.Clear()?
I want to clear all the Session variables.
I am using VS 2008/VB.Net and am trying to figure out if I should use a "Website" or a "ASP.Net Application" project type.
I have to create an online tool to allow users to manage data, there should be no more than 5-10 users at a time on the system. I need to use Profile/Membership with the tool.
I plan to use the <correction> N-layer </correction> (not "n-tier") architecture with a Business layer and DB layer.
I am wondering about the advantages/disadvantages of each.
Is the "website" model really outdated? I notice that the Website model has in built support for many more namespaces but with asp.net application does not, you have to add a lot of references.
May i know what is the Difference that they actually make in IIS7 .
tell me at a low level as i am still a novice in Asp.Net
What is the difference between; Deploying an application Releasing an application Implementing an application
View 1 RepliesI've gone rounds with this ever since I started programming classic ASP 12 (or so) years ago and I've never found a great solution because the architecture of ASP and ASP.NET has always been a swamp of bad practices, magic shared singletons, etc. My biggest issue is with the HttpApplication object with its non-event events (Application_Start, Application_End, etc.).
If you want to do stuff once for the entire lifespan of an HTTP application, Application_Start is the obvious place to do it. Right? Not exactly. Firstly, this is not an event per se, it's a magic naming convention that, when followed, causes the method to be called once per AppDomain created by IIS.
Besides magic naming conventions being a horrible practice, I've started to think it might be a reason there exist no such thing as a Start event on the HttpApplication object. So I've experimented with events that do exist, such as Init. Well, this isn't really an event either, it's an overridable method, which is the next best thing.
It seems that the Init() method is called for every instantiation of an HttpApplication object, which happens a lot more than once per AppDomain. This means that I might as just put my startup logic inside the HttpApplication object's constructor.
Now my question is, why shouldn't I put my startup logic in the constructor? Why does even Init() exist and do I need to care about Application_Start? If I do, can anyone explain why there is no proper event or overridable method for this pseudo-event in the HttpApplication object?
And can anyone explain to me why in a typical ASP.NET application, 8 instances of my HttpApplication are created (which causes the constructor and Init to run just as many times, of course; this can be mitigated with locking and a shared static boolean called initialized) when my application only has a single AppDomain?
Is that possible to get access to Session, Cache, Server.MapPath() from a class in App_code?
View 1 Repliesmy ASP.NET application reads an xml file to determine which environment it's currently in (e.g. local, development, production).
It checks this file every single time it opens a connection to the database, in order to know which connection string to grab from the Application Settings.
I'm entering a phase of development where efficiency is becoming a concern. I don't think it's a good idea to have to read a file on a physical disk ever single time I wish to access the database (very often).
I was considering storing the connection string in Application["ConnectionString"].
[code].....
I didn't design the application so I figure there must have been a reason for reading the xml file every time (to change settings while the application runs?) I have very little concept of the inner workings here. What are the pros and cons?
I have several web sequential pages which will modify a record and its child records in the database, called a "project". Such a project is currently passed between pages using its database ID in the URL parameters.
A project has some information specific to itself, and also consists of one or more Tasks, which each have information specific to itself.
Is it faster (alternatively, more maintainable or more easily understood) to hit the database each time I need to query the same project (and its tasks), or should I query the database once (either once for each page or once for all pages and save to Session) and check the saved object rather than the database?
I have a DataTable with about 10,000 rows in it.
I would like to store this data once for aspx page. When the user selects different options in the page, data is further selected from the already stored DataTable.
I tried using the ViewState, but as soon as the data grows beyond 100 rows, performance degrades.
When I first implemented forms authentication I consulted an article that told me to store the user's custom IPrincipal object in the cache. Is this wrong? Should I have stored it in the session?
View 1 RepliesI need to know what is Cache size. I've read solution on this site for more or less similar question but it partly serves me. As i know i can get values from PerMon, here is function
public static string getCacheSize()
{
PerformanceCounter pc = new PerformanceCounter("ASP.NET Applications", "Cache % Machine Memory Limit Used","__TOTAL__", true);
return string.Format("{0:0.00}%", pc.NextValue());
}
1.it gives me percents when i need KB and there is no item closest to this one in PerfMon
2.it shows 70.5% used while all memory usage is about 50%
have a situation very similar to the one in this question:http://stackoverflow.com/questions/774695/selective-cache-clearing-across-load-balanced-servers-asp-netThe difference is that due to our hosting configuration, I am unable to address individual servers by IP address. Assuming I cannot access specific servers via web requests, is it possible to access the HttpContext of a web application running on the same machine? I'm thinking I could accomplish this with a windows service that I could address by machine name, or alternately a console application
View 1 RepliesI just noticed a "Cache" object, when would you use the Cache object to store state data nd when would you use the Application object?
View 1 RepliesI would like to create a web application that gives an overview of all latests builds of a Team Foundation Server (TFS). The original idea was to simply query the TFS for all these builds and display the results using html. Now the problem is that this is just too slow. It takes around a minute to get the required informtion. I can't inluence this, it is just given. So I came up with the idea of caching. I could cache all results for a certain period of time and then invalidate the cache but as soon as the cache expires someone that uses the application will have to wait again which is not that nice.
The Team Foundation Server is able to notify whenever a new build is available. So basically the idea is that the application could react on that notification. In order to be notified I have to write a web service and register it with the TFS. That worked pretty well so far. The web service is now notified whenever a new build is done. Now I would like to connect my web application to the web service and whenever the web service is notified by the TFS update the cache of the web application. Here starts the problem. How can this be achieved? First I thought that the web service could fire a .NET event and the web application could react on that event but that does not seem to be possible. The next idea was that both the web service and the web application could use the same cache. The web service could then directly update the cache with the build information it receives from the Team Foundation Server but I am not even sure if this works.
Can a web service and a web application share the same cache? The web service doing something like Cache.Add("key", buildInfo) and the web application buildInfo = Cache["key"]. If not what other approach could be used to solve such a scenario?
How do I force a control+F5 (deleting cache) when updating an application? The users will not do this so I need to force this. Can we use some kind of flush method checking version or...?
View 1 RepliesI would like to reset/clear an item in the Cache, but without resetting the application or writing a specialized page just for this. ie, a non-programmatic solution.
View 3 RepliesI have a asp.net web application and I'm using cache (HttpRuntime.Cache) to save some stuff from db.
I also update db from time to time so that data in db does not match the data in my application's cache.
Is there any way how to clear my application's cache without modifying any source code or republishing the page?
I tried to restart IIS and to clear browsers cache