473,748 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Return image link with webservice

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


Nov 8 '07 #1
3 6119
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
Nov 8 '07 #2
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


Nov 8 '07 #3
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
Nov 8 '07 #4

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

Similar topics

1
4411
by: John Scott | last post by:
I am storing an image in an SQL database and have one field as an image datatype. I am also using a webservice to transport data. I want to be able to resize the image and pass back a thumbnail image in a byte of what is in the database. I also want to be able to display this image in an <asp:image></asp:image> control. Is there any way to do this? Most of the examples that I've seen have used
12
4127
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport) {
13
2352
by: Neo Geshel | last post by:
I have examined about 80+ different upload scripts on the 'net, both in VB and C#, and none seem to do what I need them to do. Perhaps someone here can point me somewhere that Google hasn't reached yet (I have gone all the way to page 50 on Google's results!!). Here are my requirements: • I have a DataGrid. Everything will be done from here. Everything. No exceptions. Everything will also be done in VB, without any code-behind to...
0
1145
by: Geert | last post by:
Hi all, I have a webservice that creates an image. I want to show the result of that image on my website. The website and webservice are on different servers. There is a VPN line between both servers. What is the best way to sent the image to my website? - save the file on a share - sent a stream from the webservice to the site (if it is possible to do) - save the file to http://websiteserver/tempfolder (if possible)
9
3219
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. What it does is to call a webservice with two parameters, one being a integer, the other one being a "String" which contains XML (not the best practice, however that is the target interface and we cannot change that).
2
2114
by: Nicolas | last post by:
Hello! I have a question: I have a database in MySql that has two fields (code and image). Now, I want to create a WebService that takes the image of the most current row (the code is the date in which the image took). And then, create a page in ASP.NET that calls this WebService, show the image and repeat this behavior every 5 seconds (it is the time that is take a new image be creating in the base of information). Can someone help or...
4
1763
by: Nicolas | last post by:
Hello! I have a question: I have a database in MySql that has two fields (code and image). Now, I want to create a WebService that takes the image of the most current row (the code is the date in which the image took). And then, create a page in ASP.NET that calls this WebService, show the image and repeat this behavior every 5 seconds (it is the time that is take a new image be creating in the base of information). Can someone help or...
2
7548
by: zion | last post by:
Hi, I have database with picture locations, for example: c:\temp\test.jpg. How can webservice return picture link? <img width=200 height=150 src='file://c:\\temp\\test.jpg' /> <img width=200 height=150 src='c:\\temp\\test.jpg' /> It works only if the link is:
2
9788
by: ksheerasagar17 | last post by:
Hello All, Scenario: Sending an image through webservice as byte array to an Java webservice. The Problem1: The webservice method image property expects (data type) SByte rather than Byte array. Thus i'm converting a byte array to sbyte array and sending through web service. The converted SByte contains negative numbers wihch are resulting in an error "java.lang.ArrayIndexOutOfBoundsException: -106" Byte => SByte...error...
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9552
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9249
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8245
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.