FAQ TBarCode .NET
Using TBarCode ASP.NET in Web Farms (IIS 7.0)
Using TBarCode ASP.NET in Web Farms (IIS 7.0)
If you use TBarCode ASP.NET Web Control in a Web Farm you may encounter the following exception:
Exception Type: System.ApplicationException Message: The requested image is no longer cached.
The TBarCode .NET Web Control uses the HttpContext.Cache object to store the generated barcode image. Since http requests are load balanced within a web farm it can occur that a specific Web Control receives a request for an image, which has been generated on a different application server (and therefore is not available in its local cache).
To overcome this problem you could
- Synchronize the HttpContext.Cache object on all servers in the web farm (="distributed caches"). This could be done with extra programming or additional third party software.
- or simply use Client Affinity in IIS 7.0 (recommended)
Having client affinity enabled all requests are tagged with a cookie so that subsequent requests (from the same client) are routed to the same server in the web farm.
See Application Request Routing (Step 3 – Configure client affinity)
Application Request Routing provides a client affinity feature that maps a client to a content server behind Application Request Routing for the duration of a client session. When this feature is enabled, the load balancing algorithm is applied only for the very first request from the client.![]()