473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Injecting image page element without calling ASPX page?

I'm wondering if there's a solution here -

I have an ASPX page with a sole purpose of scaling an image. The ASPX page
contains a single line with the codebehind tag, and the .cs file contains
the code to read an image, use GDI+ to scale it to a reasonable size, and
emit the image directly (setting content-type on the response and spitting
out the bytes for the image).

What I'd love to do would be to eliminate the ASPX page and be able to call
a routine in my compiled code directly. Since this code will be delivered to
a customer, that would get rid of the extra ASPX page and make it much more
elegant.

But since the ASPX page is called in an "img" tag, I can't see a way to do
this. Obviously, I need the img tag in the display file, but is there a way
to specify that the content comes from code rather than another page? Can
the img tag be runat-server and inject the image directly in codebehind?

Anyone have a clue for me?

Many thanks!

Christopher
Nov 17 '05 #1
2 2337
"Christopher Ambler" <ch***@ambler.net> wrote in
news:ud**************@tk2msftngp13.phx.gbl:
But since the ASPX page is called in an "img" tag, I can't see a way
to do this. Obviously, I need the img tag in the display file, but is
there a way to specify that the content comes from code rather than
another page? Can the img tag be runat-server and inject the image
directly in codebehind?


I don't think so... because the browser needs to create a new connection to
download the graphics image. The new connection would contain the binary
image data. If you placed all the code on one page, the binary data would
be mixed in with your html data, thus corrupting the display : (

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 17 '05 #2
HttpHandlers I understand - I implemented one to do image download control
(intercepted requests for .JPG and return "Please do not directly access
this image").

So what you're saying is, instead of implemeting an ASPX file with the
codebehind, implement an HttpHandler. Instead of calling an IMG tag with the
ASPX page and the image I want served on the command line, call and IMG tag
with, say, the source as "dir1/dir2/imagename.xxx" where "xxx" is any
extension I want. I could then have the handler intercept that call, parse
the URI to find the image, perform its magic, and return the image.

Nice! I'd not considered this solution. Many thanks!

Christopher

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:eC**************@tk2msftngp13.phx.gbl...
"Christopher Ambler" <ch***@ambler.net> wrote in message
news:ud**************@tk2msftngp13.phx.gbl...
I'm wondering if there's a solution here -

I have an ASPX page with a sole purpose of scaling an image. The ASPX page contains a single line with the codebehind tag, and the .cs file contains the code to read an image, use GDI+ to scale it to a reasonable size, and emit the image directly (setting content-type on the response and spitting out the bytes for the image).

What I'd love to do would be to eliminate the ASPX page and be able to call
a routine in my compiled code directly. Since this code will be

delivered to
a customer, that would get rid of the extra ASPX page and make it much more
elegant.


You are describing an HttpHandler. See "
Securely Implement Request Processing, Filtering, and Content Redirection
with HTTP Pipelines in ASP.NET"

at(http://msdn.microsoft.com/msdnmag/is...s/default.aspx ). Here's an example .ashx file from that article:

<%@ WebHandler language="C#" class="Pipeline.TimeHandler" %>

using System;
using System.Web;

namespace Pipeline
{

public class TimeHandler : IHttpHandler
{
void ProcessRequest(HttpContext ctx)
{
// set response message MIME type
ctx.Response.ContentType = "text/xml";
// write response message body
ctx.Response.Write("<now>");
ctx.Response.Write(
DateTime.Now.ToString());
ctx.Response.Write("</now>");
}
bool IsReuseable { get { return true; } }
}
}

--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

Nov 17 '05 #3

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

Similar topics

4
by: Marc Pelletier | last post by:
Hello, I have a class (TideClass) which creates a bitmap image as one of its functions. I want to create a page which has this image embedded amongst some text. I know that I have to stream the...
11
by: tma | last post by:
I have the following HTML in use on my web page. I need it to show a graphic image on the page but do not know what to use in the codebehind to make the graphic appear. If I load the source url in...
0
by: Jeronimo Bertran | last post by:
Hi, I have a page that includes an image that uses an image map. When the user clicks on a button, the image needs to be refreshed and the map needs to be updated without refreshing the entire...
8
by: Lars Netzel | last post by:
Hey! I wrote a message yersterday and got some good answers and have now managed to generate a nice image. The problem is that it's all generated in an Images.Aspx file and I don't really want...
3
by: ACaunter | last post by:
Hi there, I was wondering if there was a way to crop a peice of an ASP.Net Image, allowing the user to zoom in on only a section of the picture?? any help would be appreciated!! thanks --...
17
by: Luke Matuszewski | last post by:
Hi ! Simple question (but thus it may appear no simple answer): If i putting a script onto the page i simply could inline it in <script> element or via its src attribute so (second way): <script...
4
by: MikeB | last post by:
Hello All, want to be able to pull images from the database and load them into a bitmap through a stream which I have working. I then want to take the bitmap and load it into a Image control...
7
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. I have an ASP.NET 2.0 web application which contains an Images directory with all website images. How can I prevent other websites from creating img tags with the source as my images? I want...
6
by: Jeff | last post by:
hi asp.net 2.0 I have a image (.jpeg) stored in sql server 2005 and now I want to display it on a webpage. So I created a webpage (Image.aspx) which just writes the buffer data to the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
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...

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.