c# - Why is the file not downloading? -


i followed this link download file in file system. except did using ext.net link button, , in click event of button added same download code.

the design part is:

<ext:linkbutton id="lnkdownload" text="download" runat="server">         <directevents>             <click onevent="lnkdownload_click">                 <eventmask showmask="true" />             </click>         </directevents>     </ext:linkbutton> 

and codebehind is:

protected void lnkdownload_click(object s, directeventargs e)     {          string filepath = // path file         fileinfo file = new fileinfo(filepath);          if (file.exists)         {             response.clear();             response.addheader("content-disposition", "attachment; filename=" + file.name);             response.addheader("content-length", file.length.tostring());             if (file.extension == ".txt")                 response.contenttype = "application/txt";             else if (file.extension == ".jpg")                 response.contenttype = "image/jpg";             else                 response.contenttype = "application/octet-stream";             context.response.writefile(file.fullname);             response.end();         }         else         {             response.write("this file not exist.");         }     } 

when running code, error occurs. text content displayed text file, , maybe encrypted image content displayed image file. happening? why file not downloading? please me how solve.

the snapshots are:

enter image description hereenter image description here

for work change code following:

<ext:linkbutton id="lnkdownload" text="download" runat="server">         <directevents>             <click onevent="lnkdownload_click" isupload="true">                 <eventmask showmask="true" />             </click>         </directevents> </ext:linkbutton> 

note: think content type should "application/octet-stream".

edit

for mask, per daniil ext.net team, its not possible without workaround.

the code

<ext:linkbutton id="lnkdownload" text="download" runat="server">         <directevents>             <click onevent="lnkdownload_click" success="ext.net.directmethods.download({ isupload : true });" isupload="true">                 <eventmask showmask="true" />             </click>         </directevents> </ext:linkbutton> 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -