开发者

ASP.NET Image Control not updated after ImageUrl change

开发者 https://www.devze.com 2023-03-21 01:58 出处:网络
I\'m fairly new to ASP.NET and of course happened to stumble some strange problem. Problem is very popular, but none of the replies I found worked for me.

I'm fairly new to ASP.NET and of course happened to stumble some strange problem.

Problem is very popular, but none of the replies I found worked for me.

I have a simple image:

<asp:Image ID="userImage" runat="server" ImageAlign="Right" />

And in codebehind:

If Not Session("selecteduser") Is Nothing Then
    userImage.ImageUrl = "~/showphoto.aspx?user=" & Session("开发者_高级运维selecteduser")
End If

And the image doesn't change. It doesn't even fire up the showphoto.aspx code. The property is changed (because next time i step into it, it's changed), but showphoto is never fired.

I'm aware of image caching issues, but I can't get even one image, not mentioning have it changed. For sure there's a very simple explanation, but I'm fighting with this for 2 days now to no avail.


I think the problem may be one of the following:

  1. There is nothing in the session object "selecteduser" which might cause that the imageurl property not set. ( Resolution: debug your code to confirm that there is a session object )

  2. The image url is being setted but the image is not changed which might be a problem of browser caching. (Resolution: Append the current date time to the list of query string parameters to force the browser to load the new image).

  3. "showphoto.aspx" is a page and not an image so it return html code which is not translated to image. (Resolution:Change the content-type property of this page to be image

0

精彩评论

暂无评论...
验证码 换一张
取 消