Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Best way to get database images from Web Service

Posted on 2010-08-27
5
Medium Priority
?
478 Views
Last Modified: 2013-11-07
I'm working on a mobile web site and web service where the images are stored in the database. For the web site, I'm using the following markup to display a stored image:
<img id="MyImage" runat="server" EnableViewState="false"
    src='<%# Eval("ImageFileID", "~/HttpHandlers/DBImageHandler.ashx?fileid={0}") %>' alt=""
/>

Open in new window


But other web sites may call my web service and need access to the stored images. Should I just have the web method return the ResolveURL value of "~/HttpHandlers/DBImageHandler.ashx?fileid={0}" or is there a better way?

Or is it sufficient if I just return the ImageFileID and document how the caller should make use of that information?

Thanks in advance.
0
Comment
Question by:ZekeLA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 31

Accepted Solution

by:
MlandaT earned 500 total points
ID: 33548343
Should I just have the web method return the ResolveURL value of "~/HttpHandlers/DBImageHandler.ashx?fileid={0}" or is there a better way?
I think yes... however... remember that other sites WILL NOT BE ABLE to use the "~/HttpHandlers" as it refers to your machine... pretty much like 'localhost'... so perhaps rather return the full url including the domain name e.g. http://www.mydomain.com/HttpHandlers/DBImageHandler.ashx?fileid=1
0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 33548810
Hi,

Why don't you create a WebMethod in WebService which takes the Id from client to retrieve image from database. And then return the byte array of the image back to the client. And on the client side in your web application use those byte array values in MemoryStream to retrieve image from the same.

Why ? Because no need of providing clients the URL as some of malicious user can misuse them. (It's my assumption only, your choice to accept it or not).

Regards,
VSS
0
 
LVL 1

Author Comment

by:ZekeLA
ID: 33549492
That's what I meant to say MlandaT when i said I would use ResolveURL. I realize I have to give them the rendered URL. I appreciate the confirmation.

VSS, that's what the handler does. But the client could be almost anything; it won't necessarily be be .NET. How well can other platforms take an array of bytes back and convert it into an image?
0
 
LVL 1

Author Comment

by:ZekeLA
ID: 33549503
My other issue was making the web method result small. Returning just the FileID is less than providing the entire url. But it requires the client to create the image's url. And it isn't flexible if our website organization changes. I could always put the base url in a returned soap header so it only gets sent once per call.
0
 
LVL 16

Assisted Solution

by:Vikram Singh Saini
Vikram Singh Saini earned 500 total points
ID: 33549547
Hi,

I agree with comment at ID:33549492. I was thinking that in .Net context. But for comment at ID:33549503 you said that if our website organization changes. For that you can save your images url in database along with file id. And so when you changes organization update those url values in database.

Regards,
VSS
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question