Thursday, March 29, 2012

newbie: image problems again

hey

asp.net 2.0

my problem is that on a webpage am I trying to dynamically display the image
a user has uploaded. But the webpage doesn't display the image. The browser
displays the standard image telling that image not found / broken image link
etc...

This is the code which saves the image to hard drive...:
fullsizeImage.Save(Server.MapPath("~/Images/Fullsize/" + Profile.UserName +
".jpeg"));

This is my code for displaying the image, it's in Page_Load event of
webpage:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/" + Profile.UserName
+ ".jpeg");

The image exist in that folder

Any suggestions to this error?

JeffHi Jeff,

does this variable "Profile.UserName" really exist when you try to load the
image. Did you place an exception-handler around the loading-method?

Bye,

--
Matthias Pieroth
www.codegod.de - The Page for .NET-developers

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:%23qlAzL5nGHA.1808@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
my problem is that on a webpage am I trying to dynamically display the
image a user has uploaded. But the webpage doesn't display the image. The
browser displays the standard image telling that image not found / broken
image link etc...
>
This is the code which saves the image to hard drive...:
fullsizeImage.Save(Server.MapPath("~/Images/Fullsize/" + Profile.UserName
+ ".jpeg"));
>
This is my code for displaying the image, it's in Page_Load event of
webpage:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/" +
Profile.UserName + ".jpeg");
>
The image exist in that folder
>
Any suggestions to this error?
>
Jeff
>


Hey

it looks like Profile.UserName is empty...
But this code doesn't work either:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/test.jpeg");

I've also tryed this (setting it directly in the source, not the code
behind):
src='<%# Eval("~/Images/Fullsize/test.jpeg") %>'
Without any success...

any suggestions?

Jeff

"Matthias Pieroth" <piermat2001@.yahoo.dewrote in message
news:e8elch$p0k$02$1@.news.t-online.com...

Quote:

Originally Posted by

Hi Jeff,
>
does this variable "Profile.UserName" really exist when you try to load
the image. Did you place an exception-handler around the loading-method?
>
Bye,
>
--
Matthias Pieroth
www.codegod.de - The Page for .NET-developers
>
>
"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:%23qlAzL5nGHA.1808@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>hey
>>
>asp.net 2.0
>>
>my problem is that on a webpage am I trying to dynamically display the
>image a user has uploaded. But the webpage doesn't display the image. The
>browser displays the standard image telling that image not found / broken
>image link etc...
>>
>This is the code which saves the image to hard drive...:
>fullsizeImage.Save(Server.MapPath("~/Images/Fullsize/" + Profile.UserName
>+ ".jpeg"));
>>
>This is my code for displaying the image, it's in Page_Load event of
>webpage:
>imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/" +
>Profile.UserName + ".jpeg");
>>
>The image exist in that folder
>>
>Any suggestions to this error?
>>
>Jeff
>>


>
>


Hi Jeff,

I am not sure what your problem is, but try one of these two things:
1. If you are using something like VS.Net, then simply try to locate a
test image using the properties grid of the Image Control. And then try
to run your page and see if it works.

2. try printing the path you are trying to assign to the ImageUrl
property by using a Response.Write() from the code behind.
So basically Response.Write(Server.MapPath("~\....

I have a feeling you are doing a bit too much in trying to assign a
path to the ImageUrl property.

- V

Jeff wrote:

Quote:

Originally Posted by

Hey
>
it looks like Profile.UserName is empty...
But this code doesn't work either:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/test.jpeg");
>
I've also tryed this (setting it directly in the source, not the code
behind):
src='<%# Eval("~/Images/Fullsize/test.jpeg") %>'
Without any success...
>
any suggestions?
>
Jeff
>
>
"Matthias Pieroth" <piermat2001@.yahoo.dewrote in message
news:e8elch$p0k$02$1@.news.t-online.com...

Quote:

Originally Posted by

Hi Jeff,

does this variable "Profile.UserName" really exist when you try to load
the image. Did you place an exception-handler around the loading-method?

Bye,

--
Matthias Pieroth
www.codegod.de - The Page for .NET-developers

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:%23qlAzL5nGHA.1808@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
my problem is that on a webpage am I trying to dynamically display the
image a user has uploaded. But the webpage doesn't display the image. The
browser displays the standard image telling that image not found / broken
image link etc...
>
This is the code which saves the image to hard drive...:
fullsizeImage.Save(Server.MapPath("~/Images/Fullsize/" + Profile.UserName
+ ".jpeg"));
>
This is my code for displaying the image, it's in Page_Load event of
webpage:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/" +
Profile.UserName + ".jpeg");
>
The image exist in that folder
>
Any suggestions to this error?
>
Jeff
>



The path is
C:\Documents and Settings\Jeff\My Documents\Visual Studio
2005\WebSites\BN\Images\Fullsize\test.jpeg

I've checked and path is correct, but the path contains spaces...

I'm not sure about it but maybe the browser need to know if this is a
picture ("image/thumb")?

Jeff

"V" <vaibhav.gadodia@.gmail.comwrote in message
news:1152051114.522719.324780@.a14g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

Hi Jeff,
>
I am not sure what your problem is, but try one of these two things:
1. If you are using something like VS.Net, then simply try to locate a
test image using the properties grid of the Image Control. And then try
to run your page and see if it works.
>
2. try printing the path you are trying to assign to the ImageUrl
property by using a Response.Write() from the code behind.
So basically Response.Write(Server.MapPath("~\....
>
I have a feeling you are doing a bit too much in trying to assign a
path to the ImageUrl property.
>
- V
>
Jeff wrote:

Quote:

Originally Posted by

>Hey
>>
>it looks like Profile.UserName is empty...
>But this code doesn't work either:
>imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/test.jpeg");
>>
>I've also tryed this (setting it directly in the source, not the code
>behind):
>src='<%# Eval("~/Images/Fullsize/test.jpeg") %>'
>Without any success...
>>
>any suggestions?
>>
>Jeff
>>
>>
>"Matthias Pieroth" <piermat2001@.yahoo.dewrote in message
>news:e8elch$p0k$02$1@.news.t-online.com...

Quote:

Originally Posted by

Hi Jeff,
>
does this variable "Profile.UserName" really exist when you try to load
the image. Did you place an exception-handler around the
loading-method?
>
Bye,
>
--
Matthias Pieroth
www.codegod.de - The Page for .NET-developers
>
>
"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:%23qlAzL5nGHA.1808@.TK2MSFTNGP02.phx.gbl...
>hey
>>
>asp.net 2.0
>>
>my problem is that on a webpage am I trying to dynamically display the
>image a user has uploaded. But the webpage doesn't display the image.
>The
>browser displays the standard image telling that image not found /
>broken
>image link etc...
>>
>This is the code which saves the image to hard drive...:
>fullsizeImage.Save(Server.MapPath("~/Images/Fullsize/" +
>Profile.UserName
>+ ".jpeg"));
>>
>This is my code for displaying the image, it's in Page_Load event of
>webpage:
>imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/" +
>Profile.UserName + ".jpeg");
>>
>The image exist in that folder
>>
>Any suggestions to this error?
>>
>Jeff
>>
>
>


>


It is possible that you may need to grant permission to the asp.net
process on that image directory. It might be a problem with the
security.

- V
Jeff wrote:

Quote:

Originally Posted by

The path is
C:\Documents and Settings\Jeff\My Documents\Visual Studio
2005\WebSites\BN\Images\Fullsize\test.jpeg
>
I've checked and path is correct, but the path contains spaces...
>
I'm not sure about it but maybe the browser need to know if this is a
picture ("image/thumb")?
>
>
>
>
Jeff
>
>
>
>
>
"V" <vaibhav.gadodia@.gmail.comwrote in message
news:1152051114.522719.324780@.a14g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

Hi Jeff,

I am not sure what your problem is, but try one of these two things:
1. If you are using something like VS.Net, then simply try to locate a
test image using the properties grid of the Image Control. And then try
to run your page and see if it works.

2. try printing the path you are trying to assign to the ImageUrl
property by using a Response.Write() from the code behind.
So basically Response.Write(Server.MapPath("~\....

I have a feeling you are doing a bit too much in trying to assign a
path to the ImageUrl property.

- V

Jeff wrote:

Quote:

Originally Posted by

Hey
>
it looks like Profile.UserName is empty...
But this code doesn't work either:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/test.jpeg");
>
I've also tryed this (setting it directly in the source, not the code
behind):
src='<%# Eval("~/Images/Fullsize/test.jpeg") %>'
Without any success...
>
any suggestions?
>
Jeff
>
>
"Matthias Pieroth" <piermat2001@.yahoo.dewrote in message
news:e8elch$p0k$02$1@.news.t-online.com...
Hi Jeff,

does this variable "Profile.UserName" really exist when you try to load
the image. Did you place an exception-handler around the
loading-method?

Bye,

--
Matthias Pieroth
www.codegod.de - The Page for .NET-developers

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:%23qlAzL5nGHA.1808@.TK2MSFTNGP02.phx.gbl...
hey
>
asp.net 2.0
>
my problem is that on a webpage am I trying to dynamically display the
image a user has uploaded. But the webpage doesn't display the image.
The
browser displays the standard image telling that image not found /
broken
image link etc...
>
This is the code which saves the image to hard drive...:
fullsizeImage.Save(Server.MapPath("~/Images/Fullsize/" +
Profile.UserName
+ ".jpeg"));
>
This is my code for displaying the image, it's in Page_Load event of
webpage:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/" +
Profile.UserName + ".jpeg");
>
The image exist in that folder
>
Any suggestions to this error?
>
Jeff
>



I replaced this line:

imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/test.jpeg");

with this line

imgPicture.ImageUrl = "~/Images/Fullsize/test.jpeg";

And now it works

Thank you very much for helping me with this. The best thing with this
problem is that I've learned from it -maybe using Server.MapPath isn't
best all the times...

Best Regards!

Jeff

"V" <vaibhav.gadodia@.gmail.comwrote in message
news:1152057813.849114.308260@.m73g2000cwd.googlegr oups.com...

Quote:

Originally Posted by

It is possible that you may need to grant permission to the asp.net
process on that image directory. It might be a problem with the
security.
>
- V
Jeff wrote:

Quote:

Originally Posted by

>The path is
>C:\Documents and Settings\Jeff\My Documents\Visual Studio
>2005\WebSites\BN\Images\Fullsize\test.jpeg
>>
>I've checked and path is correct, but the path contains spaces...
>>
>I'm not sure about it but maybe the browser need to know if this is a
>picture ("image/thumb")?
>>
>>
>>
>>
>Jeff
>>
>>
>>
>>
>>
>"V" <vaibhav.gadodia@.gmail.comwrote in message
>news:1152051114.522719.324780@.a14g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

Hi Jeff,
>
I am not sure what your problem is, but try one of these two things:
1. If you are using something like VS.Net, then simply try to locate a
test image using the properties grid of the Image Control. And then try
to run your page and see if it works.
>
2. try printing the path you are trying to assign to the ImageUrl
property by using a Response.Write() from the code behind.
So basically Response.Write(Server.MapPath("~\....
>
I have a feeling you are doing a bit too much in trying to assign a
path to the ImageUrl property.
>
- V
>
Jeff wrote:
>Hey
>>
>it looks like Profile.UserName is empty...
>But this code doesn't work either:
>imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/test.jpeg");
>>
>I've also tryed this (setting it directly in the source, not the code
>behind):
>src='<%# Eval("~/Images/Fullsize/test.jpeg") %>'
>Without any success...
>>
>any suggestions?
>>
>Jeff
>>
>>
>"Matthias Pieroth" <piermat2001@.yahoo.dewrote in message
>news:e8elch$p0k$02$1@.news.t-online.com...
Hi Jeff,
>
does this variable "Profile.UserName" really exist when you try to
load
the image. Did you place an exception-handler around the
loading-method?
>
Bye,
>
--
Matthias Pieroth
www.codegod.de - The Page for .NET-developers
>
>
"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:%23qlAzL5nGHA.1808@.TK2MSFTNGP02.phx.gbl...
>hey
>>
>asp.net 2.0
>>
>my problem is that on a webpage am I trying to dynamically display
>the
>image a user has uploaded. But the webpage doesn't display the
>image.
>The
>browser displays the standard image telling that image not found /
>broken
>image link etc...
>>
>This is the code which saves the image to hard drive...:
>fullsizeImage.Save(Server.MapPath("~/Images/Fullsize/" +
>Profile.UserName
>+ ".jpeg"));
>>
>This is my code for displaying the image, it's in Page_Load event
>of
>webpage:
>imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/" +
>Profile.UserName + ".jpeg");
>>
>The image exist in that folder
>>
>Any suggestions to this error?
>>
>Jeff
>>
>
>
>


>

0 comments:

Post a Comment