zion explained :
Thank you for reply.
Do you have any example for this solution?
"Hans Kesting" <in************ @spamgourmet.co mwrote in message
news:mn******** *************** @spamgourmet.co m...
>zion formulated the question :
>>Hello,
How can I return image link with webservice that I could see it in web
page?
The image is on my hard disk and <img src="c:\picture s\test.jpg" /does
not
work.
If I use <img src=http://My comuter/Virtual directory/test.jpg /it's
working but I can't use this because the image path is in DB with phisycal
location.
Thanks
The C:\ path won't work as that will always point to the local C: drive for
the browser, and that's not where your images are (and the browser-machine
might not even *have* a C: drive - unix doesn't!).
If you just want to return a link to the image from the webservice, add a
handler (ashx) to the webservice site that returns the image, based on some
image-id.
The URL returned from the webservice would then be something like http://My
Computer/theSite/ImageHandler.as hx?id=1234
This would look up the local path in your db, find the image-file and
return it using Response.WriteF ile(..).
Hans Kesting
public class ImageHandler : System.Web.IHtt pHandler
{
// required by interface IHttpHandler
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest( System.Web.Http Context context)
{
int id = Int32.Parse(con text.Request["id"]);
string filename = GetFilenameFrom Database(id);
// need to implement this
// finds the full filename based on the supplied "id"
context.Respons e.ContentType = GetMimeTypeFrom Filename(filena me);
// need to implement this
// sets mimetype such as "image/jpeg"
context.Respons e.WriteFile(fil ename);
}
}
and in web.config, under <system.web>
<httpHandlers >
<add verb="GET" path="image.ash x" type="ImageHand ler" />
</httpHandlers>
Note: the "type" value is the full classname (including namespace) of
your handler-class, optionally followed by a comma and the name of the
assembly it is defined in.
You can use it like <img src="http://server/image.ashx?id=1 234">
Hans Kesting