473,624 Members | 2,103 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

would this be a possible use of an HTTPHandler?

let's say that I have a webpage with an <img> tag and it has an invalid src
attribute, that is the image it points to doesn't exist. Is there any way
to catch stuff like that and handle it? For example, if I detect a missing
image, I could instead return a NoImageAvail.jp g image instead?

Weird question and I'm not sure how to ask it, but I suspect it could be
something that could be handled somehow. Thanks.

Steve
Nov 18 '05 #1
4 991
The way i store images... most important ones are stored in the database...
as a byte array...
i extract them on db call and i check them for a null value... null would
mean not there....
if you are storing them in on hard drive... you can still use a stream
reader to read it from the hard drive into memory... instead of using a
plain vanilla <img tag>

in that case what you will need to do is check the hdd for image... if found
read it from a hard drive.. into a memory stream... and output it to client
page....

http://www.microsoft.com/belux/nl/ms...tphandler.mspx

this link is a good example on how to use custom http handler to create a
file that serves images....

you can then use <img src"the image serving file.ext?your params"> to fetch
the image... (plus you can use caching to image on server etc... to make it
faster)

Note: you can do away by just create an aspx page that does the job.. but
you dont need to (infact custom handler would be about 5% faster)

--
Regards,

HD

"Steve" <st***@nowhere. com> wrote in message
news:uE******** ******@TK2MSFTN GP11.phx.gbl...
let's say that I have a webpage with an <img> tag and it has an invalid src attribute, that is the image it points to doesn't exist. Is there any way
to catch stuff like that and handle it? For example, if I detect a missing image, I could instead return a NoImageAvail.jp g image instead?

Weird question and I'm not sure how to ask it, but I suspect it could be
something that could be handled somehow. Thanks.

Steve

Nov 18 '05 #2
-----Original Message-----
let's say that I have a webpage with an <img> tag and it has an invalid srcattribute, that is the image it points to doesn't exist. Is there any wayto catch stuff like that and handle it? For example, if I detect a missingimage, I could instead return a NoImageAvail.jp g image instead?
Weird question and I'm not sure how to ask it, but I suspect it could besomething that could be handled somehow. Thanks.

Steve

Hi Steve,

Keep the image as a Server Control. On Page_Load(), check
if the image source, exists (by using IO and a try catch
block). On the catch event, make the image source point to
your NoImageAvail.jp g image.
NOTE: This process consumes a lot of I/O processing and
could make you page load slow esp. if you have a lot of
images.
Nov 18 '05 #3
-----Original Message-----
let's say that I have a webpage with an <img> tag and it has an invalid srcattribute, that is the image it points to doesn't exist. Is there any wayto catch stuff like that and handle it? For example, if I detect a missingimage, I could instead return a NoImageAvail.jp g image instead?
Weird question and I'm not sure how to ask it, but I suspect it could besomething that could be handled somehow. Thanks.

Steve

Hi Steve,

Keep the image as a Server Control. On Page_Load(), check
if the image source, exists (by using IO and a try catch
block). On the catch event, make the image source point to
your NoImageAvail.jp g image.
NOTE: This process consumes a lot of I/O processing and
could make you page load slow esp. if you have a lot of
images.
Nov 18 '05 #4
Yes, that would most certainly be a candidate for an HttpHandler. You can
write an HttpHandler for all your image requests, and it can do much more
than just return an image when the image doesn't exist. It could modify or
generate images in any way you want on the fly, by using QueryStrings as
well.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Steve" <st***@nowhere. com> wrote in message
news:uE******** ******@TK2MSFTN GP11.phx.gbl...
let's say that I have a webpage with an <img> tag and it has an invalid src attribute, that is the image it points to doesn't exist. Is there any way
to catch stuff like that and handle it? For example, if I detect a missing image, I could instead return a NoImageAvail.jp g image instead?

Weird question and I'm not sure how to ask it, but I suspect it could be
something that could be handled somehow. Thanks.

Steve

Nov 18 '05 #5

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

Similar topics

2
2118
by: Hanse Davion | last post by:
Can anyone provide some insight on what this problem could be? I have searched the web, read forums, and all the installation documentation for the dotnetnuke feeware portal from asp.net. I am very confident that all the security settings have been configured correctly. My setup is a Windows XP 5.1, MSDE SP3, and VS2003. ----------------------------- Server Error in '/DotNetNuke' Application....
3
7956
by: Jed | last post by:
I have written an HttpHandler which I invoke through an ashx page. The HttpHandler does various things to process the request, then it is supposed to redirect to a confirmation page. Everything up to the redirect works fine, but I can't get the redirect to work. If I do a ... context.Response.Write("Hello World"); .... the HttpHandler works great and the browser loads the text fine, but if I change it to ...
4
4234
by: Igor K | last post by:
Hi all, I'm developing asp.net website. Most of the pages are aspx, but let's say, some 10% are html. For this html pages i use httphandlers to intercept calls and to perform some job on this pages. Lately I need to access Session state in HttpHandler's code. This seems to be the problem. I searched the internet for some solution, i always found advice to dervie from IHttpHandler and that will do, but obivously not.
4
5032
by: Jeremy Lew | last post by:
When my HttpHandler is processing a request when installed on a particular 2003 Server machine, the Context.Session object is null. Any idea why this might be? My handler implements IRequiresSessionState and works normally on other machines. Thanks, Jeremy
14
2082
by: qwerty | last post by:
Hi, I am using a third party win 2003 iis 6.0 to serve my website. The web site has a httphandler which does some custom jobs. When I try to invoke the httphandler from some url call, it won't start and give a 404 error on the url. I personally create a plain win 2003 iis 6.0 server locally. The
5
1596
by: the4man | last post by:
Hi all! I have an app that show images that are stored in SQL Server. To show the images on screen, until now (with the "old" ASP), I use the following code: <img src="showimage.asp?id=20" /> And in "showimage.asp" (more or less, I write from memory)
3
2158
by: Michael Schwarz | last post by:
Hi, I have a own HttpHandler running and configured like this in my web.config: <add verb="*" path="subfolder/*.ashx" type="Class,Assembly"/> Now, when turning cookieless Sessions on my HttpHandler is not working, instead my second HttpHandler is invoked, which is configured for *.ashx files.
5
4310
by: zlf | last post by:
Hello, I try to use a custom HttpHandler to add something to session, then display the original page. public void ProcessRequest(HttpContext context) { context.Session = "test"; } But, a empty page is rendered with this HttpHandler, should I add some
5
7300
by: Author | last post by:
I followed the example at http://support.microsoft.com/kb/308001/EN-US/ and created my own HttpHandler. Here is the code: using System.Web; namespace MyNameSpace { public class SyncHttpHandler: IHttpHandler
0
8236
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8679
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8621
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8335
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7159
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5563
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4079
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.