asp.net - Why doesn't the hyperlink open the file? -


earlier developer had put code using label , turned hyperlink during run time.

<asp:label id="lbl_attachment" runat="server"> </asp:label>  lbl_attachment.text = "<a href='../uploads/" +                        ds_row["attachment"].tostring() + "'>" +                        ds_row["attachment"].tostring() + "</a>"; 

but not working. changed code following open file (image/pdf/word) in new browser tab , error persists:

      hyperlinkappdoc.navigateurl =            resolveurl("../uploads/" +            ds_row["attachment"].tostring());       hyperlinkappdoc.target = "_blank";   

enter image description here

what can fix issue? mime types available in iis.


update: trying out different approach. server.mappath poiting @ local drive instead of wwwroot. how can point path wwwroot folder?

string pdfpath = server.mappath("~/somefile.pdf"); webclient client = new webclient(); byte[] buffer = client.downloaddata(pdfpath); response.contenttype = "application/pdf"; response.addheader("content-length", buffer.length.tostring()); response.binarywrite(buffer); 

you have used asp.hyperlink. following

<asp:hyperlink id="hyperlink1" navigateurl="<set_from_code_behind>" text="text redirect" runat="server"/>

and set navigateurl code behind following.

hyperlink1.navigateurl= "uploads/" + ds_row["attachment"].tostring();