473,386 Members | 1,752 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,386 software developers and data experts.

Can this be done and if so how?

I have a client application that requests many large jpeg mages from my asp
site. However these images can be programatically generated very easily and
very quickly.

Suppose my site receives a request for images/bigImage.jpg. Is it possible
for me to intercept this request and process it programatrically - say using
a processRequest? Or do I have to at least have some file called
images/bigImag.jpg on my site. Note that I can't use a query string since I
have no control over the client - it will simply request
images/bigImage.jpg.

If it is possible, where would be a good place to start looking?

Thanks for any help.

Jeff
Oct 21 '08 #1
7 889
Answer yes and no.
If you have access to IIS Management Console (meaning you have admin rights
on a server) you can associate jpg extension with ASP.NET engine and then
using Application_BeginRequest or (write a custom module or handler) do what
you want.

If you are on shared hosting you are out of luck (unless your provider will
configure that option for you)

PS: If you can create custom 404 page then it might work for you. Create
custom 404.aspx and do the job in there.

George.

"Jeff" <so*****@somewhere.comwrote in message
news:Ck********************@newsfe24.ams2...
>I have a client application that requests many large jpeg mages from my asp
site. However these images can be programatically generated very easily and
very quickly.

Suppose my site receives a request for images/bigImage.jpg. Is it possible
for me to intercept this request and process it programatrically - say
using a processRequest? Or do I have to at least have some file called
images/bigImag.jpg on my site. Note that I can't use a query string since
I have no control over the client - it will simply request
images/bigImage.jpg.

If it is possible, where would be a good place to start looking?

Thanks for any help.

Jeff

Oct 21 '08 #2

"George" <no*****@comcast.netwrote in message
news:OP**************@TK2MSFTNGP03.phx.gbl...
Answer yes and no.
If you have access to IIS Management Console (meaning you have admin
rights on a server) you can associate jpg extension with ASP.NET engine
and then using Application_BeginRequest or (write a custom module or
handler) do what you want.

If you are on shared hosting you are out of luck (unless your provider
will configure that option for you)

PS: If you can create custom 404 page then it might work for you. Create
custom 404.aspx and do the job in there.

George.
Thanks a million George, I think your idea about the custom 404 will work.
I registered a custome error module:-

<httpModules>
<add type="AspNetResources.CustomErrors4.MyErrorModule" name="MyErrorModule"
/>
</httpModules>

Now, when I receive a request for a non existant jpeg I can capture it in
MyErrorModule and look at the request. If the request is for a bitmap that I
know how to make then I make the bitmap and stream it out as a jpeg.
Othwewise I just serve up a custor error message or image.

Seems pretty straightforward. I thought it would be a lot harder than this -
maybe I'm missing something!

Thanks again
Jeff
Oct 22 '08 #3
Unfortunately it might not work in production.
Depending on which IIS version you have. On IIS 6.0 or Win2003 your request
for non-existent image *.jpg will never make it to .NET runtime. Hence your
handler will not work

George.

"Jeff" <so*****@somewhere.comwrote in message
news:vR*******************@newsfe29.ams2...
>
"George" <no*****@comcast.netwrote in message
news:OP**************@TK2MSFTNGP03.phx.gbl...
>Answer yes and no.
If you have access to IIS Management Console (meaning you have admin
rights on a server) you can associate jpg extension with ASP.NET engine
and then using Application_BeginRequest or (write a custom module or
handler) do what you want.

If you are on shared hosting you are out of luck (unless your provider
will configure that option for you)

PS: If you can create custom 404 page then it might work for you. Create
custom 404.aspx and do the job in there.

George.

Thanks a million George, I think your idea about the custom 404 will work.
I registered a custome error module:-

<httpModules>
<add type="AspNetResources.CustomErrors4.MyErrorModule"
name="MyErrorModule" />
</httpModules>

Now, when I receive a request for a non existant jpeg I can capture it in
MyErrorModule and look at the request. If the request is for a bitmap that
I know how to make then I make the bitmap and stream it out as a jpeg.
Othwewise I just serve up a custor error message or image.

Seems pretty straightforward. I thought it would be a lot harder than
this - maybe I'm missing something!

Thanks again
Jeff
Oct 22 '08 #4

"George" <no*****@comcast.netwrote in message
news:em**************@TK2MSFTNGP05.phx.gbl...
Unfortunately it might not work in production.
Depending on which IIS version you have. On IIS 6.0 or Win2003 your
request for non-existent image *.jpg will never make it to .NET runtime.
Hence your handler will not work
Thanks again

Yes, I discovered shortly after posting that this wouldn't work on a shared
hosting site - so I'm now taking the custom 404 error page route.

I set up a custom 404 which gets displayed whenver a non-existant page is
requested.
In the page_load I check if the referring url was a jpeg I can construct and
if so I stream it out to the response - otherwise I display the standard
aspx page.

Now, this again works fine on my local system, but on the shared hosting
site my attempt to stream out the image is producing a 404 which produces my
standard 404 page.
What is the correct place to send the write to the response - in the
page_load or somewhere else?

Thanks
Jeff
Oct 22 '08 #5
I did not understand this phrase
"my attempt to stream out the image is producing a 404 which produces my
standard 404 page."

I actually would check if you got your custom page 404 page working.
Just output simple "hello" and check that if you request something like
http://www.mysite.com/nopage
You get your "hello".
You might want to add folowing lines to your 404 page to clear out 404 error
code.
Response.Clear();
Response.CacheControl = "no-cache";
Response.Expires = -1;
Response.StatusCode = 200;
Response.Status = "200 Ok";

Also do not forget to set ContentType = "image"; to indicate that it's image
being produced.

George
"Jeff" <so*****@somewhere.comwrote in message
news:PO*******************@newsfe08.ams2...
>
"George" <no*****@comcast.netwrote in message
news:em**************@TK2MSFTNGP05.phx.gbl...
>Unfortunately it might not work in production.
Depending on which IIS version you have. On IIS 6.0 or Win2003 your
request for non-existent image *.jpg will never make it to .NET runtime.
Hence your handler will not work

Thanks again

Yes, I discovered shortly after posting that this wouldn't work on a
shared hosting site - so I'm now taking the custom 404 error page route.

I set up a custom 404 which gets displayed whenver a non-existant page is
requested.
In the page_load I check if the referring url was a jpeg I can construct
and if so I stream it out to the response - otherwise I display the
standard aspx page.

Now, this again works fine on my local system, but on the shared hosting
site my attempt to stream out the image is producing a 404 which produces
my standard 404 page.
What is the correct place to send the write to the response - in the
page_load or somewhere else?

Thanks
Jeff

Oct 22 '08 #6

"George" <no*****@comcast.netwrote in message
news:eN**************@TK2MSFTNGP03.phx.gbl...
>I did not understand this phrase
"my attempt to stream out the image is producing a 404 which produces my
standard 404 page."

I actually would check if you got your custom page 404 page working.
Just output simple "hello" and check that if you request something like
http://www.mysite.com/nopage
You get your "hello".
You might want to add folowing lines to your 404 page to clear out 404
error code.
Response.Clear();
Response.CacheControl = "no-cache";
Response.Expires = -1;
Response.StatusCode = 200;
Response.Status = "200 Ok";

Also do not forget to set ContentType = "image"; to indicate that it's
image being produced.

George

Once again, many thanks for your help.

I checked that my custom error page was writing stuff out ok.

What seems to be causing the problem is that my code for getting the
referring URL works ok on my local machine but apparently not on the remote
machine.
To get the referring page I put the following

string requestedPage = Request.QueryString["aspxerrorpath"];
if (!requestedPage.EndsWith("jpg"))
return;

Writing out <%=requestedPage%on my local machine produces the expected
result, writing on the shared host produces an empty string.

Thanks

Jeff


Oct 22 '08 #7
Ok, I talked with the support people at my hosting Company.
It seems like there are two ways in which my custom 404 error page is
called:

Non existant urls with an extension assocuiated with asp.net are routed
through the asp.net environment
Other non existant urls are routed through the regular IIS(?) environment.

Unfortunately the latter Urls do not have a referring url in the query
string :-(

Looks like a complete gotcha.

Thanks for all the help.
Jeff
Oct 22 '08 #8

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

Similar topics

0
by: itsharkopath | last post by:
Hi, Imagine a user in a hotspot, when he comes to the hotspot and tries to load a webpage (on the internet), he would automatically redirected to login page. I believe the following is to be...
9
by: Steven T. Hatton | last post by:
This was written for the gnu.g++.help list. It rather clearly spells out the most important feature of Java that I believe C++ lacks. I really don't believe the C++ Standard sepcifies enough for a...
16
by: jaialai technology | last post by:
I want to reload a url in a browser window so I do something like this: open(window.location.href= "www.yahoo.com"); ok, so now I want to do something when that page is done loading completely....
5
by: Morten Overgaard | last post by:
Hi I have a C# component which fires events. I want to catch these events in my MFC app compiled with the /clr. I know I can define a managed class in my MFC app which traps the events - but I...
11
by: Sharon | last post by:
I'm writing a new control derived from UserControl. I need to get an event when the control is done resizing. I tried the Resize, SizeChanged, Move and the Layout events and I also tried to...
3
by: Miguel Dias Moura | last post by:
Hi, When I subscribe a web site I usually receive an email to confirm my subscription. Only after I follow the link in the email my account gets activated. In general, how is this done? Can...
4
by: BrianDH | last post by:
Group Early this week I ask for examples on how to call a VB.NET Web Service and access its DataSet for a traditional ASP page. I was told, "you can't", "won't work", "not possible". Well I...
12
by: Ark | last post by:
Hello NG, I arrange data in structs like { members... uint16_t crc; more members, maybe... } Then I need to save them, up to and including crc, in non-volatile memory or a file, as the case...
2
by: maya | last post by:
http://news.yahoo.com/news?tmpl=index2&cid=703 down the page, under "More Stories", there's a section with two interchangeable divs which slide back and forth into view.. how is this done? I...
2
by: poolboi | last post by:
hey guys, i've done most of my web app. for searching almost done but then i got a small little problem with logging in i need to know how session tracking is done in perl if not my log in page...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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.