473,503 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IHttpHandler and Caching

Hi,

Ive got a .ashx file which produces an image (useage: <img
src="myHandler.ashx" />)

What do I need to do to make it cache? Every time my page reloads it
recreates the image (a slow process), and i have a lot of these per page.

The image-producing code doesn't NEED to be in a handler (in case anyone
has a better suggestion)

Thanks
Andrew
Nov 26 '06 #1
1 4570
Hi Andrew,

In the future you may get better responses if you post ASP.NET questions to
the microsoft.public.dotnet.framework.aspnet newsgroup.

If you're generating the image on-the-fly then you can cache the result
programmatically:

public Bitmap YourImage
{
get
{
if (Cache["YourImageKey"] == null)
Cache["YourImageKey"] = GenerateYourImage();

return (Bitmap) Cache["YourImageKey"];
}
}

"Caching Application Data"
http://msdn2.microsoft.com/en-us/library/6hbbsfk6.aspx

To allow IIS, proxy servers and the user agent (web browser) to cache the
request output you can use the following code, for example:

Response.Cache.SetCacheability(HttpCacheability.Pu blic);

"How To: Set a Page's Cacheability Programmatically"
http://msdn2.microsoft.com/en-us/library/z852zf6b.aspx

--
Dave Sexton

"Andrew" <in********@THISmuonlab.comwrote in message
news:kI*******************@newsfe3-win.ntli.net...
Hi,

Ive got a .ashx file which produces an image (useage: <img
src="myHandler.ashx" />)

What do I need to do to make it cache? Every time my page reloads it
recreates the image (a slow process), and i have a lot of these per page.

The image-producing code doesn't NEED to be in a handler (in case anyone
has a better suggestion)

Thanks
Andrew

Nov 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1447
by: lapin | last post by:
I'm trying to get access to session variables from an IHttpHandler class. In several places I've seen the solution posted as in this message: >If you define your own custom HttpHandler, you need...
1
3063
by: lapin | last post by:
I'm trying to get access to session variables from an IHttpHandler class. In several places I've seen the solution posted as in this message: >If you define your own custom HttpHandler, you...
13
4281
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
5
1992
by: vimakefile | last post by:
I'd like to have the concept of a Page (different code-behind file for each url, session state, etc.) but be able to specify my own custom HTTP payload. (I don't want to use any Asp.Net forms,...
0
1048
by: Stu | last post by:
Hi, I am trying to write a basic httphandler to 'fake' that pages actually exist. I have copied the code below from various sites - but the line 'Implements IHttpHandler' reports an error "type...
2
8025
by: bryan | last post by:
I can't find much info on what makes an instance of the handler reusable. If it maintains no internal state, I would assume that it is safe to be reusable - correct? I have one that grabs a value...
24
2725
by: John Rivers | last post by:
ASPX which means ASPX pages, the code-behind concept, User Controls, Web Controls etc. is very poorly designed and makes it extremely hard to develop professional quality web applications. ASPX...
1
4294
by: Aartware | last post by:
I've read all the items about the IHttpHandler and the session-object and I see nothing wrong with my code, but still I have no session object. This is my code: Imports System Imports...
0
1186
by: shapper | last post by:
Hello, I am using an ASP.NET 3.5 SP1 and a while ago I created an IHttpHandler that transforms a Sitemap XML file to a compatible Google Sitemap (https://www.google.com/webmasters/tools/docs/en/...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.