ASP.NET Loading images to my page.aspx causing some weird errors ( sometimes! ) -
as can guess title, loading players database (microsoft sql server 2012) players.aspx page, , ofcourse every player has photo..
and happening when i'm trying load players.aspx..? weird errors happening, 1 after another, that's weird.
i explain more detailed:
i'm loading 100 players in same time (still no paging), means i'm loading 100 photos page @ once, guess encumber page , caused issue, changed stored procedure returning me players database select top (10)
reduced number of players should load in page, issues repated on , over, , when commented part getting image, works well, don't understand why happening, , why app keeps breaking when images loaded rest of attributes...
and have issues not happen everytime, example run app - hitting f5 - debug, fine, did again, boom boom, , on...
here code - players.aspx -code behind page i'm loading players photos.
public partial class players : system.web.ui.page { protected void page_load(object sender, eventargs e) { try { this.form.defaultbutton = this.btnsearch.uniqueid; if (!ispostback) { var currentclub = system.web.httpcontext.current.user.identity.name; var currentclubid = system.web.httpcontext.current.user.identity; if (securityservices.isauthorized(currentclub) == true) { repeaterplayers.datasource = daplayers.selecttop10players(); //before selectall() repeaterplayers.databind(); } else { var club = daplayers.getclubbyname(currentclub); repeaterplayers.datasource = daplayers.selectplayersbyclubid(club.clubid); repeaterplayers.databind(); } } } catch { } }
and here players.aspx
<table class="table table-hover" style="margin-top: 50px; background-color: white;"> <tr> <th>firstname</th> <th>lastname</th> <th>photo</th> </tr> <asp:repeater id="repeaterplayers" runat="server" onitemcommand="repeaterplayers_itemcommand"> <itemtemplate> <tr> <td><%# eval("firstname") %></td> <td><%# eval("lastname") %></td> <td> <asp:image id="imagetest" runat="server" style="width: 60px; height: 30px;" imageurl='<%#"~/imagehandler.ashx?id="+eval("playerid") %>' </td> </tr> </itemtemplate> </asp:repeater> </table>
and said if comment part work fine! never face error !: (code below, images loading)
<asp:image id="imagetest" runat="server" style="width: 60px; height: 30px;" imageurl='<%#"~/imagehandler.ashx?id="+eval("playerid") %>'
and here imagehandler.ashx code:
public class imagehandler : ihttphandler { public void processrequest(httpcontext context) { int playerid = convert.toint32(context.request["id"]); player newplayer =daplayers.getbyplayerid(playerid); context.response.contenttype = "image/jpeg"; context.response.binarywrite(newplayer.photo); } public bool isreusable { { return false; } }
and here issues facing when load image database:
i must once again, not happening everytime trying load players players.aspx page, happens pretty often!
and code simple can't figure out why happening, , talking 900 images in database, not reason guess because tried top 10 also.... :))
thanks guys cheers
Comments
Post a Comment