ASP.NET 2.0 - ASP:Image and empty ImageUrl causes invalid <img> tag - by Rune Gulbrandsen

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


3
0
Sign in
to vote
ID 330201 Comments
Status Closed Workarounds
Type Bug Repros 3
Opened 2/26/2008 11:22:58 PM
Access Restriction Public

Description

When using an asp:Image control with no ImageUrl the HTML will be <img src=""> this causes the browser to do a page request to the default page of the website/folder the page is placed in.

This caused problems for me since the page_load of the default page replaced some initial values that the second page needed. (And gave me about 5 hrs extra of debugging time to find the problem ;) ) The workaround for me was to give the <asp:Image> control an initial visible="false" value so that it isn't rendered before I manually set's the value to true and a valid imageurl. 

I have seen this in the asp.net forum too, but the response of the posts there has been that MS hasn't been able to reproduce it.
Sign in to post a comment.
Posted by slickompressor on 6/4/2008 at 12:22 PM
I was able to reproduce the issue exactly as specified.
Posted by Microsoft on 3/3/2008 at 6:57 PM
We were able to reproduce the reported behavior. In this specific case the combination of the empty string and a default page on the web server causes the reported behavior.

There are a few workarounds:

-Always set ImageUrl to a valid value.
-Don't emit an image tag if there is no valid image Url to reference
-As noted in the bug report, render the image tag but set the style to not visible.
-Use a dummy image (e.g. something like blank.png) as a placeholder.

We decided against changing the output rendering of the Image control given the available workarounds.

Thank you for taking the time to submit this issue.
Posted by Microsoft on 2/27/2008 at 9:32 PM
Thanks for your feedback.

We are escalating this issue to the appropriate group within the Visual Studio Product Team for triage and resolution.
These specialized experts will follow-up with your issue.

Thank you,
Visual Studio Product Team