Embedding another page into my page

S

S. Justin Gengo

Another possibility would be to use a web request and a literal control.
This is the method I prefer because you can check if the request is valid
and handle the possibility of the page you're requesting not showing up...

Something along these lines:

'---Create the request

Dim WebRequest As System.Net.WebRequest = System.Net.WebRequest.Create(New
Uri(CurrentLink))

WebRequest.Timeout = 2000

'---Get the response produced by the request

Dim Response As System.Net.WebResponse = WebRequest.GetResponse

'---Download the page content into a stream

Dim Stream As System.IO.Stream = Response.GetResponseStream

'---Place the stream into a stream reader

Dim StreamReader As New System.IO.StreamReader(Stream)

'---Read the stream into a string object

Dim HtmlReceived As String = StreamReader.ReadToEnd

'---Place the string into a literal control

Literal1.Text = HtmlReceived

'---Cleanup

Stream.Close()

StreamReader.Close()


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
J

J-T

Thanks for the reply.

I used the way that you suggested ,but the problem is that it is returing
relative path to the picture which is in the page and because that picture
dosen;t exist in my website ,the picture is not showig up well.Page contains
a relative path to the picture and page is not part of my website,I am
getting its content from a website to which I have to access.When I use
iframe the whole page is rendered and then I don;t care about the paths in
the page.

Any suggesions?

Thanks agian
 
J

J-T

Thanks guys ,it works very well.My only problem is that I have to refresh
the content of the iframe every 2 minues ,I am palcing this iframe in a user
control which is loaded by an aspx page .I used java script code in the user
control to refresh it every 2 minutes ,but it seems that refreshing the user
control dosen;t refresh the content of the iframe.

Any ideas?

Thanks
 
S

S. Justin Gengo

J-T,

Is it always the same picture you're after? Or will the url change?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
S

S. Justin Gengo

In that case you could create a .aspx page that sends the image to you using
the response object.

You would then set the link of your image to the imagedelivery.aspx page.

The code for the delivery page would be like this:

'------------------------------------------------------------------------------------------
'Sub: Page_Load DateCreated:8/26/2005 By: S. Justin Gengo DateModified:
By:
'
' Comments:
' Delivers an image from the image table stored in memory as a stream.
'------------------------------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim MemoryStream As System.IO.Stream
Try
Response.Clear()
Response.ContentType = "image/jpeg"

Dim ImageWebRequest As System.Net.WebRequest

ImageWebRequest = System.Net.WebRequest.Create(New
Uri("http://www.mywebapp/uri of image here.jpg"))
ImageWebRequest.Timeout = 2000

'---Get the response produced by the request
Dim Response As System.Net.WebResponse =
ImageWebRequest.GetResponse

'---Download the page content into a stream
MemoryStream = Response.GetResponseStream

Response.BinaryWrite(MemoryStream.GetBuffer)
Catch ex As Exception
'---Handle any errors here.
Finally
If Not MemoryStream Is Nothing Then
MemoryStream.Close()
MemoryStream = Nothing
End If
End Try
End Sub


Then set your link to the image delivery page. You could even tack on a
random number as a querystring id to the default page's url each page load
something like:

Image1.ImageUrl = "http://www.mywebapp.com/imagedelivery.aspx?id=" &
Rnd.ToString & Rnd.ToString

The query string will make the client browser think that the image url has
changed every page load. Thus, no caching of images.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
J

J-T

Sorry,I guessed I am misleading you by bad explanation.

The source is a page that contains the image :

http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website

page gif.asp ultimately contians this picture :cam3_ttcc_00001.jpg !The
picture is being updated every 2 minues and that's why I need to update my
hosting user control in 2 minutes as well to show latest picture.I have no
access to the image so any relative path to the image dosen;t work,the only
thing I have access to is the URL I mentioned above.

Thanks a lot for the help
 
S

S. Justin Gengo

J-T,

In the code I sent you put the image url itself into the code:

ImageWebRequest = System.Net.WebRequest.Create(New
Uri(http://www.tehrantraffic.com/cam3_ttcc_00001.jpg))

That's why I was asking if the image name changed. As long as the image name
will always be "_ttcc_00001.jpg then the code I gave you will work. Plus you
can handle an error if for some reason a request for the image doesn't go
through and you can make certain it will never be cached on the client...


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
J

J-T

That's cool.I didn;t know that I can have access to that image directly
through the url.You probably found it from its relative path .I didn;t
notice that .Good point .

Now that I have the url of the picture ,rather than the url of the hosting
page ,I guess it is easier to follow.The only question is this line of code:
Response.BinaryWrite(MemoryStream.GetBuffer)
I am using C# and MemoryStream of type System.IO.Stream dosesn;t give me the
GetBuffer method? How can I get that method?

I so appreciate your help
 
S

S. Justin Gengo

J-T,

Actually, it's even easier than that...

You don't even need the page I created at all, unless you want to double
check that the image is available.

If you don't care if it doesn't show up every now and then you could just
set your image url directly to it.

again I'd tag on random numbers to the query string to stop caching...

http://www.tehrantraffic.com/cam3_ttcc_00001.jpg?id=2

But if you do want to check whether the image is being delivered or not then
the GetBuffer method is available from C# also...

Try it out:

Response.Clear;

Response.ContentType = "image/gif";


System.Net.WebRequest ImageWebRequest;

ImageWebRequest = System.Net.WebRequest.Create(New
Uri("http://www.tehrantraffic.com/cam3_ttcc_00001.jpg"));

System.Net.WebResponse WebResponse = ImageWebRequest.GetResponse;

System.IO.MemoryStream MemoryStream = Response.GetResponseStream;


MemoryStream.GetBuffer();


Response.BinaryWrite(MemoryStream.GetBuffer);


MemoryStream.Close();

MemoryStream = Nothing;



Oh, and i think I know why you don't see the GetBuffer method... You are
probably not seeing quite a few interesting methods...

In Visual Studio go to the menu and click Tools - Options.

In the window that opens Click the "Text Editor" folder in the left hand
pane. Then Click the "C#" folder.

In the Right hand pane uncheck the "Hide Advance Members" checkbox.


--
Sincerely,


S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
J

J-T

Justin,

I really appreciate your vauable help.The reason I was not able to see the
GetBuffer method was that in the previous code you created MemoryStream
from
System.IO.Stream and now you changed it to MemoryStream :) I just wondered
that why you have chosen the name of memory stream and then creaed your
object from Stream class !!

No problem .I am going to implement it and let you know if there is any
problem by the end of today .Thanks a lot again



S. Justin Gengo said:
J-T,

Actually, it's even easier than that...

You don't even need the page I created at all, unless you want to double
check that the image is available.

If you don't care if it doesn't show up every now and then you could just
set your image url directly to it.

again I'd tag on random numbers to the query string to stop caching...

http://www.tehrantraffic.com/cam3_ttcc_00001.jpg?id=2

But if you do want to check whether the image is being delivered or not
then the GetBuffer method is available from C# also...

Try it out:

Response.Clear;

Response.ContentType = "image/gif";


System.Net.WebRequest ImageWebRequest;

ImageWebRequest = System.Net.WebRequest.Create(New
Uri("http://www.tehrantraffic.com/cam3_ttcc_00001.jpg"));

System.Net.WebResponse WebResponse = ImageWebRequest.GetResponse;

System.IO.MemoryStream MemoryStream = Response.GetResponseStream;


MemoryStream.GetBuffer();


Response.BinaryWrite(MemoryStream.GetBuffer);


MemoryStream.Close();

MemoryStream = Nothing;



Oh, and i think I know why you don't see the GetBuffer method... You are
probably not seeing quite a few interesting methods...

In Visual Studio go to the menu and click Tools - Options.

In the window that opens Click the "Text Editor" folder in the left hand
pane. Then Click the "C#" folder.

In the Right hand pane uncheck the "Hide Advance Members" checkbox.


--
Sincerely,


S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
J-T said:
That's cool.I didn;t know that I can have access to that image directly
through the url.You probably found it from its relative path .I didn;t
notice that .Good point .

Now that I have the url of the picture ,rather than the url of the
hosting page ,I guess it is easier to follow.The only question is this
line of code:
Response.BinaryWrite(MemoryStream.GetBuffer)
I am using C# and MemoryStream of type System.IO.Stream dosesn;t give me
the GetBuffer method? How can I get that method?

I so appreciate your help


S. Justin Gengo said:
Oh, and change the content type in the code from jpg to gif.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Sorry,I guessed I am misleading you by bad explanation.

The source is a page that contains the image :

http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website

page gif.asp ultimately contians this picture :cam3_ttcc_00001.jpg !The
picture is being updated every 2 minues and that's why I need to update
my hosting user control in 2 minutes as well to show latest picture.I
have no access to the image so any relative path to the image dosen;t
work,the only thing I have access to is the URL I mentioned above.

Thanks a lot for the help

message In that case you could create a .aspx page that sends the image to you
using the response object.

You would then set the link of your image to the imagedelivery.aspx
page.

The code for the delivery page would be like this:

'------------------------------------------------------------------------------------------
'Sub: Page_Load DateCreated:8/26/2005 By: S. Justin Gengo
DateModified: By:
'
' Comments:
' Delivers an image from the image table stored in memory as a
stream.
'------------------------------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim MemoryStream As System.IO.Stream
Try
Response.Clear()
Response.ContentType = "image/jpeg"

Dim ImageWebRequest As System.Net.WebRequest

ImageWebRequest = System.Net.WebRequest.Create(New
Uri("http://www.mywebapp/uri of image here.jpg"))
ImageWebRequest.Timeout = 2000

'---Get the response produced by the request
Dim Response As System.Net.WebResponse =
ImageWebRequest.GetResponse

'---Download the page content into a stream
MemoryStream = Response.GetResponseStream

Response.BinaryWrite(MemoryStream.GetBuffer)
Catch ex As Exception
'---Handle any errors here.
Finally
If Not MemoryStream Is Nothing Then
MemoryStream.Close()
MemoryStream = Nothing
End If
End Try
End Sub


Then set your link to the image delivery page. You could even tack on
a random number as a querystring id to the default page's url each
page load something like:

Image1.ImageUrl = "http://www.mywebapp.com/imagedelivery.aspx?id=" &
Rnd.ToString & Rnd.ToString

The query string will make the client browser think that the image url
has changed every page load. Thus, no caching of images.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche

Always same picture.URL never gets changed!!!

Thanks

in message J-T,

Is it always the same picture you're after? Or will the url change?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Thanks for the reply.

I used the way that you suggested ,but the problem is that it is
returing relative path to the picture which is in the page and
because that picture dosen;t exist in my website ,the picture is
not showig up well.Page contains a relative path to the picture and
page is not part of my website,I am getting its content from a
website to which I have to access.When I use iframe the whole page
is rendered and then I don;t care about the paths in the page.

Any suggesions?

Thanks agian
"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com>
wrote in message Another possibility would be to use a web request and a literal
control. This is the method I prefer because you can check if the
request is valid and handle the possibility of the page you're
requesting not showing up...

Something along these lines:

'---Create the request

Dim WebRequest As System.Net.WebRequest =
System.Net.WebRequest.Create(New
Uri(CurrentLink))

WebRequest.Timeout = 2000

'---Get the response produced by the request

Dim Response As System.Net.WebResponse = WebRequest.GetResponse

'---Download the page content into a stream

Dim Stream As System.IO.Stream = Response.GetResponseStream

'---Place the stream into a stream reader

Dim StreamReader As New System.IO.StreamReader(Stream)

'---Read the stream into a string object

Dim HtmlReceived As String = StreamReader.ReadToEnd

'---Place the string into a literal control

Literal1.Text = HtmlReceived

'---Cleanup

Stream.Close()

StreamReader.Close()


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Yep! <iframe> will do.

<iframe
src="http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website"></iframe>


I'd try an <iframe> element.

HTH,
Axel Dahmen



------------------
Hi All,

There is a picture on the following URL which I want to have it
in one of
my asp.net pages .I mean I want to embed the content of this
page in my
own
page and get its image.Is there a control or tecnique which I
can
accomplish this?


http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website

Thanks a lot
 
J

J-T

Justine,

I guess my other question is that if I want to get 4 of these pitures at
four differnet URLs ,is the solution still applicable?

Thanks
S. Justin Gengo said:
J-T,

Actually, it's even easier than that...

You don't even need the page I created at all, unless you want to double
check that the image is available.

If you don't care if it doesn't show up every now and then you could just
set your image url directly to it.

again I'd tag on random numbers to the query string to stop caching...

http://www.tehrantraffic.com/cam3_ttcc_00001.jpg?id=2

But if you do want to check whether the image is being delivered or not
then the GetBuffer method is available from C# also...

Try it out:

Response.Clear;

Response.ContentType = "image/gif";


System.Net.WebRequest ImageWebRequest;

ImageWebRequest = System.Net.WebRequest.Create(New
Uri("http://www.tehrantraffic.com/cam3_ttcc_00001.jpg"));

System.Net.WebResponse WebResponse = ImageWebRequest.GetResponse;

System.IO.MemoryStream MemoryStream = Response.GetResponseStream;


MemoryStream.GetBuffer();


Response.BinaryWrite(MemoryStream.GetBuffer);


MemoryStream.Close();

MemoryStream = Nothing;



Oh, and i think I know why you don't see the GetBuffer method... You are
probably not seeing quite a few interesting methods...

In Visual Studio go to the menu and click Tools - Options.

In the window that opens Click the "Text Editor" folder in the left hand
pane. Then Click the "C#" folder.

In the Right hand pane uncheck the "Hide Advance Members" checkbox.


--
Sincerely,


S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
J-T said:
That's cool.I didn;t know that I can have access to that image directly
through the url.You probably found it from its relative path .I didn;t
notice that .Good point .

Now that I have the url of the picture ,rather than the url of the
hosting page ,I guess it is easier to follow.The only question is this
line of code:
Response.BinaryWrite(MemoryStream.GetBuffer)
I am using C# and MemoryStream of type System.IO.Stream dosesn;t give me
the GetBuffer method? How can I get that method?

I so appreciate your help


S. Justin Gengo said:
Oh, and change the content type in the code from jpg to gif.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Sorry,I guessed I am misleading you by bad explanation.

The source is a page that contains the image :

http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website

page gif.asp ultimately contians this picture :cam3_ttcc_00001.jpg !The
picture is being updated every 2 minues and that's why I need to update
my hosting user control in 2 minutes as well to show latest picture.I
have no access to the image so any relative path to the image dosen;t
work,the only thing I have access to is the URL I mentioned above.

Thanks a lot for the help

message In that case you could create a .aspx page that sends the image to you
using the response object.

You would then set the link of your image to the imagedelivery.aspx
page.

The code for the delivery page would be like this:

'------------------------------------------------------------------------------------------
'Sub: Page_Load DateCreated:8/26/2005 By: S. Justin Gengo
DateModified: By:
'
' Comments:
' Delivers an image from the image table stored in memory as a
stream.
'------------------------------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim MemoryStream As System.IO.Stream
Try
Response.Clear()
Response.ContentType = "image/jpeg"

Dim ImageWebRequest As System.Net.WebRequest

ImageWebRequest = System.Net.WebRequest.Create(New
Uri("http://www.mywebapp/uri of image here.jpg"))
ImageWebRequest.Timeout = 2000

'---Get the response produced by the request
Dim Response As System.Net.WebResponse =
ImageWebRequest.GetResponse

'---Download the page content into a stream
MemoryStream = Response.GetResponseStream

Response.BinaryWrite(MemoryStream.GetBuffer)
Catch ex As Exception
'---Handle any errors here.
Finally
If Not MemoryStream Is Nothing Then
MemoryStream.Close()
MemoryStream = Nothing
End If
End Try
End Sub


Then set your link to the image delivery page. You could even tack on
a random number as a querystring id to the default page's url each
page load something like:

Image1.ImageUrl = "http://www.mywebapp.com/imagedelivery.aspx?id=" &
Rnd.ToString & Rnd.ToString

The query string will make the client browser think that the image url
has changed every page load. Thus, no caching of images.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche

Always same picture.URL never gets changed!!!

Thanks

in message J-T,

Is it always the same picture you're after? Or will the url change?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Thanks for the reply.

I used the way that you suggested ,but the problem is that it is
returing relative path to the picture which is in the page and
because that picture dosen;t exist in my website ,the picture is
not showig up well.Page contains a relative path to the picture and
page is not part of my website,I am getting its content from a
website to which I have to access.When I use iframe the whole page
is rendered and then I don;t care about the paths in the page.

Any suggesions?

Thanks agian
"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com>
wrote in message Another possibility would be to use a web request and a literal
control. This is the method I prefer because you can check if the
request is valid and handle the possibility of the page you're
requesting not showing up...

Something along these lines:

'---Create the request

Dim WebRequest As System.Net.WebRequest =
System.Net.WebRequest.Create(New
Uri(CurrentLink))

WebRequest.Timeout = 2000

'---Get the response produced by the request

Dim Response As System.Net.WebResponse = WebRequest.GetResponse

'---Download the page content into a stream

Dim Stream As System.IO.Stream = Response.GetResponseStream

'---Place the stream into a stream reader

Dim StreamReader As New System.IO.StreamReader(Stream)

'---Read the stream into a string object

Dim HtmlReceived As String = StreamReader.ReadToEnd

'---Place the string into a literal control

Literal1.Text = HtmlReceived

'---Cleanup

Stream.Close()

StreamReader.Close()


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Yep! <iframe> will do.

<iframe
src="http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website"></iframe>


I'd try an <iframe> element.

HTH,
Axel Dahmen



------------------
Hi All,

There is a picture on the following URL which I want to have it
in one of
my asp.net pages .I mean I want to embed the content of this
page in my
own
page and get its image.Is there a control or tecnique which I
can
accomplish this?


http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website

Thanks a lot
 
S

S. Justin Gengo

J-T,

Sorry about the stream name mixup...

Yes, this solution would still be viable. For example you coud right a
Select Case statement that would pick which url to grab based on querystring
input...


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
J-T said:
Justine,

I guess my other question is that if I want to get 4 of these pitures at
four differnet URLs ,is the solution still applicable?

Thanks
S. Justin Gengo said:
J-T,

Actually, it's even easier than that...

You don't even need the page I created at all, unless you want to double
check that the image is available.

If you don't care if it doesn't show up every now and then you could just
set your image url directly to it.

again I'd tag on random numbers to the query string to stop caching...

http://www.tehrantraffic.com/cam3_ttcc_00001.jpg?id=2

But if you do want to check whether the image is being delivered or not
then the GetBuffer method is available from C# also...

Try it out:

Response.Clear;

Response.ContentType = "image/gif";


System.Net.WebRequest ImageWebRequest;

ImageWebRequest = System.Net.WebRequest.Create(New
Uri("http://www.tehrantraffic.com/cam3_ttcc_00001.jpg"));

System.Net.WebResponse WebResponse = ImageWebRequest.GetResponse;

System.IO.MemoryStream MemoryStream = Response.GetResponseStream;


MemoryStream.GetBuffer();


Response.BinaryWrite(MemoryStream.GetBuffer);


MemoryStream.Close();

MemoryStream = Nothing;



Oh, and i think I know why you don't see the GetBuffer method... You are
probably not seeing quite a few interesting methods...

In Visual Studio go to the menu and click Tools - Options.

In the window that opens Click the "Text Editor" folder in the left hand
pane. Then Click the "C#" folder.

In the Right hand pane uncheck the "Hide Advance Members" checkbox.


--
Sincerely,


S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
J-T said:
That's cool.I didn;t know that I can have access to that image directly
through the url.You probably found it from its relative path .I didn;t
notice that .Good point .

Now that I have the url of the picture ,rather than the url of the
hosting page ,I guess it is easier to follow.The only question is this
line of code:
Response.BinaryWrite(MemoryStream.GetBuffer)
I am using C# and MemoryStream of type System.IO.Stream dosesn;t give me
the GetBuffer method? How can I get that method?

I so appreciate your help


message Oh, and change the content type in the code from jpg to gif.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Sorry,I guessed I am misleading you by bad explanation.

The source is a page that contains the image :

http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website

page gif.asp ultimately contians this picture :cam3_ttcc_00001.jpg
!The picture is being updated every 2 minues and that's why I need to
update my hosting user control in 2 minutes as well to show latest
picture.I have no access to the image so any relative path to the
image dosen;t work,the only thing I have access to is the URL I
mentioned above.

Thanks a lot for the help

in message In that case you could create a .aspx page that sends the image to
you using the response object.

You would then set the link of your image to the imagedelivery.aspx
page.

The code for the delivery page would be like this:

'------------------------------------------------------------------------------------------
'Sub: Page_Load DateCreated:8/26/2005 By: S. Justin Gengo
DateModified: By:
'
' Comments:
' Delivers an image from the image table stored in memory as a
stream.
'------------------------------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim MemoryStream As System.IO.Stream
Try
Response.Clear()
Response.ContentType = "image/jpeg"

Dim ImageWebRequest As System.Net.WebRequest

ImageWebRequest = System.Net.WebRequest.Create(New
Uri("http://www.mywebapp/uri of image here.jpg"))
ImageWebRequest.Timeout = 2000

'---Get the response produced by the request
Dim Response As System.Net.WebResponse =
ImageWebRequest.GetResponse

'---Download the page content into a stream
MemoryStream = Response.GetResponseStream

Response.BinaryWrite(MemoryStream.GetBuffer)
Catch ex As Exception
'---Handle any errors here.
Finally
If Not MemoryStream Is Nothing Then
MemoryStream.Close()
MemoryStream = Nothing
End If
End Try
End Sub


Then set your link to the image delivery page. You could even tack on
a random number as a querystring id to the default page's url each
page load something like:

Image1.ImageUrl = "http://www.mywebapp.com/imagedelivery.aspx?id=" &
Rnd.ToString & Rnd.ToString

The query string will make the client browser think that the image
url has changed every page load. Thus, no caching of images.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche

Always same picture.URL never gets changed!!!

Thanks

in message J-T,

Is it always the same picture you're after? Or will the url change?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Thanks for the reply.

I used the way that you suggested ,but the problem is that it is
returing relative path to the picture which is in the page and
because that picture dosen;t exist in my website ,the picture is
not showig up well.Page contains a relative path to the picture
and page is not part of my website,I am getting its content from a
website to which I have to access.When I use iframe the whole page
is rendered and then I don;t care about the paths in the page.

Any suggesions?

Thanks agian
"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com>
wrote in message Another possibility would be to use a web request and a literal
control. This is the method I prefer because you can check if the
request is valid and handle the possibility of the page you're
requesting not showing up...

Something along these lines:

'---Create the request

Dim WebRequest As System.Net.WebRequest =
System.Net.WebRequest.Create(New
Uri(CurrentLink))

WebRequest.Timeout = 2000

'---Get the response produced by the request

Dim Response As System.Net.WebResponse = WebRequest.GetResponse

'---Download the page content into a stream

Dim Stream As System.IO.Stream = Response.GetResponseStream

'---Place the stream into a stream reader

Dim StreamReader As New System.IO.StreamReader(Stream)

'---Read the stream into a string object

Dim HtmlReceived As String = StreamReader.ReadToEnd

'---Place the string into a literal control

Literal1.Text = HtmlReceived

'---Cleanup

Stream.Close()

StreamReader.Close()


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Yep! <iframe> will do.

<iframe
src="http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website"></iframe>


I'd try an <iframe> element.

HTH,
Axel Dahmen



------------------
Hi All,

There is a picture on the following URL which I want to have
it in one of
my asp.net pages .I mean I want to embed the content of this
page in my
own
page and get its image.Is there a control or tecnique which I
can
accomplish this?


http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website

Thanks a lot
 
J

J-T

Thanks for all the nice help
S. Justin Gengo said:
J-T,

Sorry about the stream name mixup...

Yes, this solution would still be viable. For example you coud right a
Select Case statement that would pick which url to grab based on
querystring input...


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
J-T said:
Justine,

I guess my other question is that if I want to get 4 of these pitures at
four differnet URLs ,is the solution still applicable?

Thanks
S. Justin Gengo said:
J-T,

Actually, it's even easier than that...

You don't even need the page I created at all, unless you want to double
check that the image is available.

If you don't care if it doesn't show up every now and then you could
just set your image url directly to it.

again I'd tag on random numbers to the query string to stop caching...

http://www.tehrantraffic.com/cam3_ttcc_00001.jpg?id=2

But if you do want to check whether the image is being delivered or not
then the GetBuffer method is available from C# also...

Try it out:

Response.Clear;

Response.ContentType = "image/gif";


System.Net.WebRequest ImageWebRequest;

ImageWebRequest = System.Net.WebRequest.Create(New
Uri("http://www.tehrantraffic.com/cam3_ttcc_00001.jpg"));

System.Net.WebResponse WebResponse = ImageWebRequest.GetResponse;

System.IO.MemoryStream MemoryStream = Response.GetResponseStream;


MemoryStream.GetBuffer();


Response.BinaryWrite(MemoryStream.GetBuffer);


MemoryStream.Close();

MemoryStream = Nothing;



Oh, and i think I know why you don't see the GetBuffer method... You are
probably not seeing quite a few interesting methods...

In Visual Studio go to the menu and click Tools - Options.

In the window that opens Click the "Text Editor" folder in the left hand
pane. Then Click the "C#" folder.

In the Right hand pane uncheck the "Hide Advance Members" checkbox.


--
Sincerely,


S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
That's cool.I didn;t know that I can have access to that image directly
through the url.You probably found it from its relative path .I didn;t
notice that .Good point .

Now that I have the url of the picture ,rather than the url of the
hosting page ,I guess it is easier to follow.The only question is this
line of code:
Response.BinaryWrite(MemoryStream.GetBuffer)
I am using C# and MemoryStream of type System.IO.Stream dosesn;t give
me the GetBuffer method? How can I get that method?

I so appreciate your help


message Oh, and change the content type in the code from jpg to gif.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Sorry,I guessed I am misleading you by bad explanation.

The source is a page that contains the image :

http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website

page gif.asp ultimately contians this picture :cam3_ttcc_00001.jpg
!The picture is being updated every 2 minues and that's why I need to
update my hosting user control in 2 minutes as well to show latest
picture.I have no access to the image so any relative path to the
image dosen;t work,the only thing I have access to is the URL I
mentioned above.

Thanks a lot for the help

in message In that case you could create a .aspx page that sends the image to
you using the response object.

You would then set the link of your image to the imagedelivery.aspx
page.

The code for the delivery page would be like this:

'------------------------------------------------------------------------------------------
'Sub: Page_Load DateCreated:8/26/2005 By: S. Justin Gengo
DateModified: By:
'
' Comments:
' Delivers an image from the image table stored in memory as a
stream.
'------------------------------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim MemoryStream As System.IO.Stream
Try
Response.Clear()
Response.ContentType = "image/jpeg"

Dim ImageWebRequest As System.Net.WebRequest

ImageWebRequest = System.Net.WebRequest.Create(New
Uri("http://www.mywebapp/uri of image here.jpg"))
ImageWebRequest.Timeout = 2000

'---Get the response produced by the request
Dim Response As System.Net.WebResponse =
ImageWebRequest.GetResponse

'---Download the page content into a stream
MemoryStream = Response.GetResponseStream

Response.BinaryWrite(MemoryStream.GetBuffer)
Catch ex As Exception
'---Handle any errors here.
Finally
If Not MemoryStream Is Nothing Then
MemoryStream.Close()
MemoryStream = Nothing
End If
End Try
End Sub


Then set your link to the image delivery page. You could even tack
on a random number as a querystring id to the default page's url
each page load something like:

Image1.ImageUrl = "http://www.mywebapp.com/imagedelivery.aspx?id=" &
Rnd.ToString & Rnd.ToString

The query string will make the client browser think that the image
url has changed every page load. Thus, no caching of images.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche

Always same picture.URL never gets changed!!!

Thanks

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com>
wrote in message J-T,

Is it always the same picture you're after? Or will the url
change?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Thanks for the reply.

I used the way that you suggested ,but the problem is that it is
returing relative path to the picture which is in the page and
because that picture dosen;t exist in my website ,the picture is
not showig up well.Page contains a relative path to the picture
and page is not part of my website,I am getting its content from
a website to which I have to access.When I use iframe the whole
page is rendered and then I don;t care about the paths in the
page.

Any suggesions?

Thanks agian
"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com>
wrote in message Another possibility would be to use a web request and a literal
control. This is the method I prefer because you can check if
the request is valid and handle the possibility of the page
you're requesting not showing up...

Something along these lines:

'---Create the request

Dim WebRequest As System.Net.WebRequest =
System.Net.WebRequest.Create(New
Uri(CurrentLink))

WebRequest.Timeout = 2000

'---Get the response produced by the request

Dim Response As System.Net.WebResponse = WebRequest.GetResponse

'---Download the page content into a stream

Dim Stream As System.IO.Stream = Response.GetResponseStream

'---Place the stream into a stream reader

Dim StreamReader As New System.IO.StreamReader(Stream)

'---Read the stream into a string object

Dim HtmlReceived As String = StreamReader.ReadToEnd

'---Place the string into a literal control

Literal1.Text = HtmlReceived

'---Cleanup

Stream.Close()

StreamReader.Close()


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Yep! <iframe> will do.

<iframe
src="http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website"></iframe>


I'd try an <iframe> element.

HTH,
Axel Dahmen



------------------
Hi All,

There is a picture on the following URL which I want to have
it in one of
my asp.net pages .I mean I want to embed the content of this
page in my
own
page and get its image.Is there a control or tecnique which
I can
accomplish this?


http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website

Thanks a lot
 
S

S. Justin Gengo

J-T,

You're Welcome. Anytime!

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
J-T said:
Thanks for all the nice help
S. Justin Gengo said:
J-T,

Sorry about the stream name mixup...

Yes, this solution would still be viable. For example you coud right a
Select Case statement that would pick which url to grab based on
querystring input...


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
J-T said:
Justine,

I guess my other question is that if I want to get 4 of these pitures at
four differnet URLs ,is the solution still applicable?

Thanks
message J-T,

Actually, it's even easier than that...

You don't even need the page I created at all, unless you want to
double check that the image is available.

If you don't care if it doesn't show up every now and then you could
just set your image url directly to it.

again I'd tag on random numbers to the query string to stop caching...

http://www.tehrantraffic.com/cam3_ttcc_00001.jpg?id=2

But if you do want to check whether the image is being delivered or not
then the GetBuffer method is available from C# also...

Try it out:

Response.Clear;

Response.ContentType = "image/gif";


System.Net.WebRequest ImageWebRequest;

ImageWebRequest = System.Net.WebRequest.Create(New
Uri("http://www.tehrantraffic.com/cam3_ttcc_00001.jpg"));

System.Net.WebResponse WebResponse = ImageWebRequest.GetResponse;

System.IO.MemoryStream MemoryStream = Response.GetResponseStream;


MemoryStream.GetBuffer();


Response.BinaryWrite(MemoryStream.GetBuffer);


MemoryStream.Close();

MemoryStream = Nothing;



Oh, and i think I know why you don't see the GetBuffer method... You
are probably not seeing quite a few interesting methods...

In Visual Studio go to the menu and click Tools - Options.

In the window that opens Click the "Text Editor" folder in the left
hand pane. Then Click the "C#" folder.

In the Right hand pane uncheck the "Hide Advance Members" checkbox.


--
Sincerely,


S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
That's cool.I didn;t know that I can have access to that image
directly through the url.You probably found it from its relative path
.I didn;t notice that .Good point .

Now that I have the url of the picture ,rather than the url of the
hosting page ,I guess it is easier to follow.The only question is this
line of code:
Response.BinaryWrite(MemoryStream.GetBuffer)
I am using C# and MemoryStream of type System.IO.Stream dosesn;t give
me the GetBuffer method? How can I get that method?

I so appreciate your help


in message Oh, and change the content type in the code from jpg to gif.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Sorry,I guessed I am misleading you by bad explanation.

The source is a page that contains the image :

http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website

page gif.asp ultimately contians this picture :cam3_ttcc_00001.jpg
!The picture is being updated every 2 minues and that's why I need
to update my hosting user control in 2 minutes as well to show
latest picture.I have no access to the image so any relative path to
the image dosen;t work,the only thing I have access to is the URL I
mentioned above.

Thanks a lot for the help

in message In that case you could create a .aspx page that sends the image to
you using the response object.

You would then set the link of your image to the imagedelivery.aspx
page.

The code for the delivery page would be like this:

'------------------------------------------------------------------------------------------
'Sub: Page_Load DateCreated:8/26/2005 By: S. Justin Gengo
DateModified: By:
'
' Comments:
' Delivers an image from the image table stored in memory as
a stream.
'------------------------------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim MemoryStream As System.IO.Stream
Try
Response.Clear()
Response.ContentType = "image/jpeg"

Dim ImageWebRequest As System.Net.WebRequest

ImageWebRequest = System.Net.WebRequest.Create(New
Uri("http://www.mywebapp/uri of image here.jpg"))
ImageWebRequest.Timeout = 2000

'---Get the response produced by the request
Dim Response As System.Net.WebResponse =
ImageWebRequest.GetResponse

'---Download the page content into a stream
MemoryStream = Response.GetResponseStream

Response.BinaryWrite(MemoryStream.GetBuffer)
Catch ex As Exception
'---Handle any errors here.
Finally
If Not MemoryStream Is Nothing Then
MemoryStream.Close()
MemoryStream = Nothing
End If
End Try
End Sub


Then set your link to the image delivery page. You could even tack
on a random number as a querystring id to the default page's url
each page load something like:

Image1.ImageUrl = "http://www.mywebapp.com/imagedelivery.aspx?id="
& Rnd.ToString & Rnd.ToString

The query string will make the client browser think that the image
url has changed every page load. Thus, no caching of images.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche

Always same picture.URL never gets changed!!!

Thanks

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com>
wrote in message J-T,

Is it always the same picture you're after? Or will the url
change?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Thanks for the reply.

I used the way that you suggested ,but the problem is that it is
returing relative path to the picture which is in the page and
because that picture dosen;t exist in my website ,the picture is
not showig up well.Page contains a relative path to the picture
and page is not part of my website,I am getting its content from
a website to which I have to access.When I use iframe the whole
page is rendered and then I don;t care about the paths in the
page.

Any suggesions?

Thanks agian
"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com>
wrote in message Another possibility would be to use a web request and a literal
control. This is the method I prefer because you can check if
the request is valid and handle the possibility of the page
you're requesting not showing up...

Something along these lines:

'---Create the request

Dim WebRequest As System.Net.WebRequest =
System.Net.WebRequest.Create(New
Uri(CurrentLink))

WebRequest.Timeout = 2000

'---Get the response produced by the request

Dim Response As System.Net.WebResponse = WebRequest.GetResponse

'---Download the page content into a stream

Dim Stream As System.IO.Stream = Response.GetResponseStream

'---Place the stream into a stream reader

Dim StreamReader As New System.IO.StreamReader(Stream)

'---Read the stream into a string object

Dim HtmlReceived As String = StreamReader.ReadToEnd

'---Place the string into a literal control

Literal1.Text = HtmlReceived

'---Cleanup

Stream.Close()

StreamReader.Close()


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Yep! <iframe> will do.

<iframe
src="http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website"></iframe>


I'd try an <iframe> element.

HTH,
Axel Dahmen



------------------
Hi All,

There is a picture on the following URL which I want to have
it in one of
my asp.net pages .I mean I want to embed the content of this
page in my
own
page and get its image.Is there a control or tecnique which
I can
accomplish this?


http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC website

Thanks a lot
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,061
Latest member
KetonaraKeto

Latest Threads

Top