Caching - What Techniques Should Be Used To Handle Objects In Asp.net Cache To Prevent Problems From Multiple Worker Threads Access

Sep 8, 2010

since asp.net contains multiple threads that are executing at the same time.so if 2 threads access an object (simple or complex) that i got from the the asp.net httpcontext Cache.can't this lead to state problems on that object if these 2 theads tried to modify/read it at the same time?so what kind of precautions should i implement?for example i am thinking maybe locking the object while working with it? (wont this cause performance problems?)or maybe when i retrieve some object from the cache i should create a copy from it?
or maybe i dont need to worry about this issue at all?

View 2 Replies


Similar Messages:

C# - Shared Messaging Queue For Multiple Worker Threads In IIS?

Nov 1, 2010

I'm currently trying to interface our new intranet (ASP-MVC) with the web front end of our pager system. The pager system's front end is about 10 years old, poor interface and no documentation. To do this I have the form on the intranet post to the server, our server then sends an HTTP POST to the pager server that mimics what its own form sends.

While testing this for overloading (we sent about 10 messages almost concurrently) the pager server crashed, as the system is a black box and the only difference we noticed was the concurrent POSTs the least we can do is try to prevent this happening.I want to have all messages go into a queue that sends at most once every 5-10 seconds but I'm not sure how to implement this,

I didn't specify this earlier but the process should be synchronous from the point of view of the browser, ie webserver gets the http POST request from the browser, message is put into the queue, message is sent from the queue, webserver sends http response to the browser. This is not a high volume service and I expect simultaneous requests to be rare so response will be near instantaneous, it is more of a throttle to prevent potential issues with concurrent requests.

View 2 Replies

Caching - How To Cache A List Of Objects

Jan 23, 2010

I have a List of objects in an asp.net page. when the page loads in the browser for the first time, I fetch data from the database, create objects with those data and populate the list. All these are done inside the page load event handler. Now when the page is posted back to the page, the previous list is gone, since the variables were all freed.

How can I cache that List, so that when this page is posted back, all my objects are available?

View 5 Replies

Architecture :: Distributed Caching / Keeping Cache In Sync Between Multiple Webservers Or Even Better Farm Cache Management To Another Server?

Feb 26, 2010

I've got a web application that runs of a state server. It looks like soon it may need to distributed and there will be two web servers behind a load balancer.

This works great for session state but my next challenge is Cache

My application leverages heavily of cache. I understand ASP.Net 4.0 will be offering more here but nothing much has been said about the how too.

There are two challenges that I face

1). Each webserver will have its own copy of cache whereas it would be more efficient to put this to a third server the same as session state is put to state server.

2). The real challenge is keeping cache in sync if a simple dataset derived from the database is changed my code dumps that cache item and reloads the cache. That's all well on one webserver but webserver number two wont know to drop that particular cache item and reload it. This could cause some unexpected problems in the application.

For scenario number 2 I could attempt to do some smart coding so server number two knows to dump the cache and reload it.

My guess is someone else has already been here before and there's probably a better implementation approach rather than writing extra code.

Does anyone know how I could achieve the goal of keeping Cache in sync between multiple webservers or even better farm Cache management to another server?

View 2 Replies

Web Forms :: Prevent Browser From Caching Image - Trsponse.Cache.NoStore Didn't Work

Feb 22, 2011

[Code]....

How to prevent browser from caching image, Trsponse.Cache.NoStore didn't work

View 3 Replies

Iis - Web Garden - Max Worker Threads?

Oct 5, 2010

I'm investigating some performance improvements that can be made to our web server and ASP.NET application.This page contains a few things that we can do.We currently have two worker processes running as a garden. Do each of these worker processes have their own ASP.NET threadpool? Or do both of these worker processes share a single threadpool and the max number of worker threads is shared across these processes?This post seems to suggest that the two processes share a common ASP.NET threadpool. All w3wp.exe threads do is take requests from HTTP.SYS queue, process it, and hand the request toASPNET_ISAPI.DLL, who then deposits those requests into the ASP.Net request queue, and the ASP.Net threadsBut this post suggests that each worker process contains their own ASP.NET threadpool. Each process (w3wp.exe) has its own CLR thread pool which has the configured maxworkerthreads value (20 default).

View 1 Replies

Architecture :: Handle BL Cache For Multiple Web Applications?

Mar 27, 2010

I recently received a project that contains multiple web applications with no MVC structure. For starters I've created a library (DLL) that will contain the main Business Logic. The problem is with Caching - If I use the current web context cache object than I might end up with duplicate caching (as the web context will be different for every application).

I'm currently thinking about implementing a simple caching mechanism with a singleton pattern that will allow the different web sites (aka different application domains) to share their "caching wisdom". I'd like to know what is the best way to solve this problem.

View 3 Replies

Forms Data Controls :: Caching DataTable - Create/cache Multiple DataTables?

Jul 23, 2010

Among the many aspects of asp.net that I haven't focused my development on yet is caching. I have a perfect application for it now, I think, with a GridView that sits inside a repeater, and is bound in the Repeater ItemDataBound event. The contents of the GridView will remain static for each Repeater data item for each Client. The nature of the data in the GridView is that it can change from day to day per Client, but wouldn't need to be refreshed more frequently than that. The Page istelf only deals with one at a time Client based on a QueryStringParameter. My questions are a) how do I cache the DataTable so that a call to the DataBase isn't made each time Repeater item is bound and b) can I create/cache multiple DataTables (one for each Client) and let them live for day, checking for existence before calling the SQL stored procedure to regenerate the data?

My DataTable method: [Code]....

View 2 Replies

When Develop The Key Dependecy Cache Techniques, Get A Error

Apr 6, 2010

I have to develop the Key dependecy cache techniques. I have tried this. i got the error. I have shown the details below.

HttpContext.Current.Cache.Insert(
Dim MyDependency
As
New CacheDependency(Nothing, keys)"SqlPubsEmployees",
ds, MyDependency)

View 1 Replies

MVC :: Handle Strongly Typed Views If Have Multiple Objects/models?

Mar 16, 2011

<p>Hi</p> <p>I'm a newbie in MVC but a veteran web forms developer. I really like the idea of strongly typed views but what if I have multiple objects to pass to my razor view. Would I then NOT use strongly typed views and just use the ViewBag?</p>

View 3 Replies

C# - Implement System.Web.Caching.Cache Object In A Controller To Cache Specific Query?

Mar 29, 2010

Is it correct to implement my caching object like this in my controller :

[code]....

And I Use it like this :

[code]....

View 1 Replies

Trying To Get A Better Handle On How Threads Work?

Aug 20, 2010

I'm trying to get a better handle on how threads work in ASP.NET, so I have a test site with a few pages, and I have a test WinForms client that creates 40 roughly concurrent requests to the test site. The requests take about 5-10 seconds to complete--they call a web service on another server. When I run the test client, I can use Fiddler to see that the requests are being made concurrently. However, when I look at Performance Monitor on the web server, with counters "ASP.NET Apps v2.0.xxx/Requests Executing", "ASP.NET/Requests Current", "ASP.NET Requests Queued", these counters never display more than 2.

This is the case regardless of whether the test page I'm requesting is set up with Async=True and using the Begin/End pattern of calling the web service, or if it's set up to make the call synchronously. Judging by what I see in Fiddler, I would think I should be seeing a total of 40 requests in one of those states, but I don't. Why is that? Do these counters not mean what I think they mean?

View 1 Replies

Architecture :: Cache The Full List Of Objects In Http Cache On The Service Tier And Page In Memory?

Feb 25, 2011

We have a wfc layer that wraps the business classes and database access and use a client that lives on the database layer. Amongst our group we are attempting to form standards. Some want to have the client call the web method and pass the page they are requesting and the page size. Pass that to the database and then page in SQL Server use RowNum.Some want to cache the full list of objects in http cache on the service tier and page in memory. They concern here is memory use on the server.

Which would be best for a medium number of users with potentially large number of records to manage (say 30K) Is it better to cache them all in memory and work from there or page at the database as the application scales?

View 1 Replies

Prevent IIS From Reusing Worker Processes For Separate AppDomains

Sep 21, 2010

When IIS restarts an ASP.Net (2.0) web application, it can either:

Recycle the AppDomain: Unload the AppDomain and load a new AppDomain on the same process (e.g. when HttpRuntime.UnloadAppDomain() is called, when web.config is changed).
Recycle the process: unload the AppDomain and load a new one on a new process (e.g. when invoking Recycle command on an AppPool via inetmgr, or when memory limit is reached).

Due to some internal reasons (trouble with legacy native code we depend upon), we cannot allow the first option. We just can't load the application twice on the same process.

Can IIS be somehow told to never allow worker process reuse?

I've tried preventing it myself by tracking whether an application has already started on a process once using a Mutex, and if so - throwing an exception during Application_Start()); I've also tried terminating the process by calling Environment.Exit() during Application_End(). The problem with both methods is that it causes any requests that arrive during Application_End or Application_Start to fail (unlike a manual process recycle, which fails absolutely no requests because they are redirected to the new process right away).

View 2 Replies

Queue Access To The Database To Avoid Multiple Cache Items?

Jun 7, 2010

I have a music related ASP.NET web site which caches a lot of static information from the database on the first request.Sometimes, the application is reset and cache is cleared while the application is on heavy load and then all http requests go to the database to retrieve that static data and cache it for other requests.

How can I ensure that only one request go to the database and cache the results, so that other request simply read that info from cache and not needlessly retrieve the same info over and over again.Can I use thread locking? For example, can I do something like lock(this) { db access here }?

View 2 Replies

MVC :: How To Cache MVC Page - Donut Caching With .NET

Oct 1, 2010

[OutputCache (Duration=20, VaryByParam="None" )]
public ActionResult display()
{}

This code cache whole page.But, my site has user infomation on top like this ASP.net. The user info "Signed as userid | Edit Profile | ..." section should be changed when user sign in/out. But rest of the page is always same and it's good to Cache.

If the above code is used, the user info on top also cached and give wrong info to user.

View 11 Replies

State Management :: Best Practise For Caching Objects For A List Of?

Dec 7, 2010

I've created a blog for my first asp.net website. Ive got a blog class as my object. Ive created a number of methods to access my blog articles using LINQ to SQL.

Each method returns a list of objects ready to be used in the appropriate web user control.

In my head i need to cache these lists of objects that are returned, but need to know the best way of approaching this. So i have come up with two possible options

1: Make one method to retrieve all blogs in a list<Blog> and cache this list to be used for all other methods or

2: Cache only the required methods that really need it.

View 3 Replies

C# - Caching Through HttpContext.Current.Cache Or Just A Static?

Mar 28, 2011

Last night I wrote up my first IHttpModule to do some request processing. I'm using a regular expression to inspect the raw url. The IHttpModule will be called on every request, so it seems reasonable to do some sort of caching of the regular expression object to prevent creation of it on every request.

Now my question... what is better: use the HttpContext.Current.Cache to store the instantiated object or to use a private static Regex in my module?I'm looking forward to the reasons why. Just to clarify: the regex will never change and thus always be the same thing.

View 3 Replies

Caching - How To Hold Current Date In Cache

Jul 28, 2010

I am building a web application using asp.net (c#) and lingtosql. When I perform update operations on my db I update my classes. I use gridview to bind to update information. When I relay solely on the database the page's take very long to load. When I relay solely on the cache, I have old data. What workarounds do I have for have asynchronous cache updating, yet not overload the database with endless requests (I'd like to update the cache only if there has been a change in the database itself, and perform the update operation asynchronously).

View 1 Replies

Caching - What Is The Default Serialization Used By The HttpRuntime.Cache

Jan 29, 2010

what the default serialization used by the ASP.net HttpRuntime.Cache is? Is it Binary, XML, something else?

I am populating a generic List with multiple objects of the same custom type. The custom type is a POCO, there is nothing special about it. All of its properties are public with { get; set; }, it is public, it has no inheritance, it has no interfaces. In fact it is much less complicated than many other objects which we are caching which work without issue. I have tried adding the [Serializable] attribute to the custom class and it has no effect.

I add the list to the cache with a unique key. The list has been verified as populated before it is inserted into the cache, the objects in the list have been verified as populated as well. But when the list is pulled back out of the cache it is an empty list (NOT NULL), it simply has no items in it. This means that the list is being added to the cache and is retrievable but for some reason the cache is having issues serializing the objects in the list.

I just find this freaky weird since I have another list of custom objects which are much more complicated (consisting of Inheritance, Interfaces, and also containing Properties which are generic lists of other complex objects) and the caching of those lists work without issue.

Both the working and non-working list are being managed in C# classes outside of the ASP.net user controls which consume the cached data. Both of these cache handling classes call the exact same Cache Manager class singleton instance which wraps the HttpRuntime.Cache to provide typed methods for pull and pushing objects into the cache.

Here is the class

[code]....

View 2 Replies

Caching - Cache Render Of Calendar Control?

Sep 8, 2010

We display an ASP.NET calendar control and update the color and if the day is enabled with the DayRender event. This process is a bit slow so I'm trying to map out a strategy to cache the results of the all the DayRenders. Basically take a snapshot of the calendar and cache it for X minutes. Where would I hook into the page/control workflow to accomplish this goal?

View 1 Replies

Enterprise Library Caching - Remove Objects From Outside Process (console App)

Aug 13, 2010

We are thinking about using the enterprise library caching framework in our asp.net 3.5 application to store small datatables of our most hit products. Is there a way to write an outside process, like a console application, to remove these datatables, if needed? For example, a client can come in and update the data for a product, which will make the datatable stored in cache out of date. When this happens, I would like an outside application go into the cache and remove or even update the cache with the new data.

View 1 Replies

Mobiles :: Prevent Caching In Devices

Oct 29, 2010

I am devloping ASPX pages and I want to prevent caching of pages. So i have used the following code:

<% @OutputCache Location = "None" Duration="1" VaryByParam="none" %>

But this code is working only for the desktop browsers. This is not working in mobile browsers.

View 2 Replies

Caching - Controlling Output Cache Memory Usage?

May 17, 2010

I would like to use output caching with WCF Data Services and although there's nothing specifically built in to support caching, there is an OnStartProcessingRequest method that allows me to hook in and set the cacheability of the request using normal ASP.NET mechanisms.

But I am worried about the worker process getting recycled due to excessive memory consumption if large responses are cached. Is there a way to specify an upper limit for the ASP.NET output cache so that if this limit is exceeded, items in the cache will be discarded?

I've seen the caching configuration settings but I get the impression from the documentation that this is for explicit caching via the Cache object since there is a separate outputCacheSettings which has no memory-related attributes.

Here's a code snippet from Scott Hanselman's post that shows how I'm setting the cacheability of the request.

[code]....

View 1 Replies

System.Web.Caching.Cache Doesn't Seem To Refresh Itself On Time

Jan 27, 2011

I am using System.Web.Caching.Cache in an assembly used by my website.

I have set some key expiration (absolute expiration) to be 10 seconds (just for debugging).

I have also set a callback upon key removal.

The problem is that I see that the cache is getting refreshed after something like 20 seconds and not 10.

I am using HttpRuntime.Cache for this.

I would like to show a code sample, which can shed more light:

[code]....

What could be the problem ?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved