Serving an image

N

Not Me

Hi there,

I am just wanting to simply load up an image and pass it on through the
webserver.. i.e. the client would receive the file as if they'd entered the
URL of a picture directly (using response-contenttype I guess), but really
it's a URL to an aspx page with querystring (where I decide which image to
pass on).

It's for an app that only reads from web URLs but my images are on a shared
folder, accessible to my webserver but not the app... if that makes sense!

cheers,
Chris
 
P

Patrice

Try for example :
http://www.developerfusion.co.uk/show/5223/

An ASHX handler allows to avoid the ASP.NET page cycle that is not needed.
You could use Response.WriteFile to write down the image content to the
browser (the sample grabs the picture from a db).

If not covered, please be more specific about the specific step on which you
need help...
 
N

Not Me

Hi Patrice,

Thank you for that link, it certainly looks like a more streamlined solution
to use the ashx handler instead.

My problem now is going off at a tangent, but maybe you can help.

If I use the file.OpenRead() functions, I get an
UnauthorizedAccessException, however if I simply use an asp:image, with
imageURL value of the same path - that works fine! Any ideas? The path is
along the lines of "\\servername\share\file.jpg" and I'm using integrated
windows authentication - with the authenticated user having permissions on
\\servername.

Thank you for your help,
Chris
 
P

Patrice

I would trust the exception. Not sure what you meant exactly by having
access to \\servername but are you 100 % sure the user has access to BOTH
the file system location and the network share (most often I would say
granting access to the network share is forgotten) ?

You could perhaps try a tool such as filemon from www.sysinternals.com to
track file operations failures (or ask your admin if enabling auditing
could help). You could also try to create a file (and check its owner to see
if impersonation is properly done as expected).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top