0

My concept is about stegnography. I want to play the video file and keep the download option. If the client clicks the download button, the video along with registration message should download.

I used the following code

in .cs

 DirectoryInfo dir = new DirectoryInfo(MapPath("~/Video"));
    FileInfo[] files = dir.GetFiles();
    ArrayList listItems = new ArrayList();
    foreach (FileInfo info in files)
    {
        listItems.Add(info);
    }
    DataList1.DataSource = listItems;
    DataList1.DataBind();

in design

        Font-Names="Verdana" Font-Size="Small" RepeatColumns="3" RepeatDirection="Horizontal"

        Width="600px" ForeColor="#333333">                
                <ItemTemplate>                

            <br />          
            <b>Song Name:</b>
            <asp:Label ID="lblCName" runat="server" Text='<%# Bind("name") %>'></asp:Label>
            <br />
          <video controls="controls"  width="200" height="200" src='<%# Eval ("name","Video/{0}") %>'></video>
            <br />
            <b>Download:</b>
           <asp:LinkButton ID="LinkButton1" runat="server" Text='<%#Eval("name") %>'></asp:LinkButton>              


here download option is not working, can any 1 give some idea for this plz.

ΩmegaMan
  • 29,542
  • 12
  • 100
  • 122

1 Answers1

0

The best[*] way to download a big file, like a video, is to use a handler.

So you create a handler that send the file and you send the parametres of what file to download on the url. For example you can do something like:

 <b>Download:</b> <a target="_blank" href="download.ashx?name=<%#Eval("name") %>'>"><%#Eval("name") %>'></a>

And on the handler download.ashx you read the parameter "name" and you send that file.

This also can help you:
What is the best way to download file from server
asp.net ashx handler prompting download instead of displaying file
files download using HTTP Handler

[*]Why is the best way to use a hander ?:

  1. Have the minimum of code compare with an aspx page.
  2. Have clear return - Send only what you render on output.
  3. Did not use session, so did not felt into the session lock and you avoid time outs
Community
  • 1
  • 1
Aristos
  • 66,005
  • 16
  • 114
  • 150
  • thanks for ur reply, but can you provide me code for download.aspx – user3856392 Jul 19 '14 at 18:17
  • this asp.net ashx handler prompting download instead of displaying file, this file I used, but showing error in filename, which is not mentioned – user3856392 Jul 19 '14 at 18:24
  • @user3856392 you have write `give some idea for this plz` and thats I did. I can not predict what exactly you try to do, and I do not understand whats your issue. – Aristos Jul 19 '14 at 19:00