Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. How to download executable file

How to download executable file

Scheduled Pinned Locked Moved WPF
questionalgorithmssecuritytutoriallounge
18 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F fjparisIII

    There is a SaveFileDialog class in Silverlight, but it doesn't do what you're speculative Save As dialog would do. I believe I have to read about Isolated Storage and the ways around it. I believe I know how to download a System.IO.Stream from my Website. The problem then is saving that stream outside of Isolated Storage, which is a security violation. But there must be a way to ask to do that, which forces out the "Download File - Security Warning" dialog. I just have to figure out how to do that.

    Richard Andrew x64R Offline
    Richard Andrew x64R Offline
    Richard Andrew x64
    wrote on last edited by
    #8

    I'm not the expert on Silverlight, but I would suspect that the only way to break out of Isolated Storage is by installing your application as a full-trust app, which is not possible for a web application. Read about the different trust levels, that may provide some clues.

    F 1 Reply Last reply
    0
    • F fjparisIII

      Maybe I'm looking at this the wrong way. Maybe the "File Download - Security Warning" dialog is coming directly from the Windows operating system because you're trying to write a file to the local machine from a Web browser. So maybe my question should be, how do I write to a file outside of Isolated Storage? Once I know how to get around the security issues that prevent that, the "File Download" dialog will be produced automatically. Please let me know. Am I on the right track? I just need some guidance here.

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #9

      I can tell with some certainty that that dialog box is coming from the browser, as evidenced by the fact that Firefox has its own version of it which is different from IE's version. As I said above, read about trust levels.

      1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        I'm not the expert on Silverlight, but I would suspect that the only way to break out of Isolated Storage is by installing your application as a full-trust app, which is not possible for a web application. Read about the different trust levels, that may provide some clues.

        F Offline
        F Offline
        fjparisIII
        wrote on last edited by
        #10

        I know that Websites successfully download executable files all the time. Any Website that sells its programs where you can download them right there on the spot does it. There's nothing special the user has to do to enter the Website. All they have to do to get the download is to go through the "Download File -- Security Warning" dialog. Maybe there is no way around it if all your Website programming is in in the Silverlight app, which runs on the client. But Silverlight doesn't have to be the whole site. It can just be part of it. I have developed a commercial desktop program that I want to sell through the Web, and I have contracted a Website developer that is doing the bulk of the Website programming for me (since I'm out of my league there). He can't figure out how to download my installation program, which we've uploaded to the Website itself. He says he's "still working on it." I was just fishing around up here to see if anyone had any ideas. Turns out I was probably asking the wrong question. Unfortunately, I still don't know what the right question is.

        Richard Andrew x64R 1 Reply Last reply
        0
        • F fjparisIII

          I know that Websites successfully download executable files all the time. Any Website that sells its programs where you can download them right there on the spot does it. There's nothing special the user has to do to enter the Website. All they have to do to get the download is to go through the "Download File -- Security Warning" dialog. Maybe there is no way around it if all your Website programming is in in the Silverlight app, which runs on the client. But Silverlight doesn't have to be the whole site. It can just be part of it. I have developed a commercial desktop program that I want to sell through the Web, and I have contracted a Website developer that is doing the bulk of the Website programming for me (since I'm out of my league there). He can't figure out how to download my installation program, which we've uploaded to the Website itself. He says he's "still working on it." I was just fishing around up here to see if anyone had any ideas. Turns out I was probably asking the wrong question. Unfortunately, I still don't know what the right question is.

          Richard Andrew x64R Offline
          Richard Andrew x64R Offline
          Richard Andrew x64
          wrote on last edited by
          #11

          Well let's be clear, it's not the website that's downloading the file when you purchase a program over the net. It's the user and his browser who is downloading the file. That's why the system allows you to save the file anywhere you want, because it's you doing it. On the other hand, your Silverlight app is restricted in where it can save files because it's not under the direct control of the local user, and it could very well be malicious. ( Not that yours is malicious, just saying...) Maybe there is a way you can have your app direct the browser itself to the URL from which it can download the file, and that would provide the functionality you seek.

          F 1 Reply Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            Well let's be clear, it's not the website that's downloading the file when you purchase a program over the net. It's the user and his browser who is downloading the file. That's why the system allows you to save the file anywhere you want, because it's you doing it. On the other hand, your Silverlight app is restricted in where it can save files because it's not under the direct control of the local user, and it could very well be malicious. ( Not that yours is malicious, just saying...) Maybe there is a way you can have your app direct the browser itself to the URL from which it can download the file, and that would provide the functionality you seek.

            F Offline
            F Offline
            fjparisIII
            wrote on last edited by
            #12

            This isn't a Silverlight problem. I have to put a regular HTML page behind our Silverlight Download button.

            1 Reply Last reply
            0
            • F fjparisIII

              Every one of us has downloaded dozens of executable files from the Web, but for the life of me I can't find out how this is done. Every time you go to a commercial site that offers software for free or for sale, you can click on a download button and a standard dialog with the title, "File Download - Security Warning," pops up with Run, Save, and Cancel buttons. What do you have to do to bring up this dialog? This obviously isn't a Silverlight-specific question, but searching the general Web forums mysteriously don't seem to answer this question, either. But I have to get this standard dialog coming up from my Silverlight app. If you could just point me to the right subject in a book somewhere, I'd be eternally grateful. I know there are security issues about downloading executable files. Nevertheless it's done all the time, through this standard "File Download - Security Warning" dialog that is undoubtedly available through thousands of Websites. I don't understand why this seems to be such hidden knowledge. I have several books on Website development and there isn't a word about this in any of them. Where is it actually documented how to do this?

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #13

              This is achieved by the use of Mime types and is very easy to do. Consider the following sample ASP.NET page

              :<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

              <html xmlns="http://www.w3.org/1999/xhtml" >
              <head runat="server">
              <title>Untitled Page</title>
              </head>
              <body>
              <form id="form1" runat="server">
              <div>
              <a href="~/googletoolbar2user.exe" runat="server">Exe</a>
              </div>
              </form>
              </body>
              </html>

              Clicking the link when it's running prompts the browser to display the warning you're after. Have a look at this post[^] to see more information on what you need configuring in IIS. There's no special voodoo, and I'm not surprised that books on ASP.NET don't teach this as it's more about general web development rather than Silverlight/ASP.NET issues.

              "WPF has many lovers. It's a veritable porn star!" - Josh Smith

              As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

              My blog | My articles | MoXAML PowerToys | Onyx

              F 1 Reply Last reply
              0
              • P Pete OHanlon

                This is achieved by the use of Mime types and is very easy to do. Consider the following sample ASP.NET page

                :<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

                <html xmlns="http://www.w3.org/1999/xhtml" >
                <head runat="server">
                <title>Untitled Page</title>
                </head>
                <body>
                <form id="form1" runat="server">
                <div>
                <a href="~/googletoolbar2user.exe" runat="server">Exe</a>
                </div>
                </form>
                </body>
                </html>

                Clicking the link when it's running prompts the browser to display the warning you're after. Have a look at this post[^] to see more information on what you need configuring in IIS. There's no special voodoo, and I'm not surprised that books on ASP.NET don't teach this as it's more about general web development rather than Silverlight/ASP.NET issues.

                "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                My blog | My articles | MoXAML PowerToys | Onyx

                F Offline
                F Offline
                fjparisIII
                wrote on last edited by
                #14

                So in otherwords, behind our Silverlight Download button, we have to put a regular HTML page like your example. Now it's making a heck of a lot more sense. Shows how ignorant I am of this entire world of Web programming. Thanks a lot. It probably sounds incredibly basic to you, but all this is entirely new to me, so new that I don't even know how to pose the right questions.

                M 1 Reply Last reply
                0
                • F fjparisIII

                  So in otherwords, behind our Silverlight Download button, we have to put a regular HTML page like your example. Now it's making a heck of a lot more sense. Shows how ignorant I am of this entire world of Web programming. Thanks a lot. It probably sounds incredibly basic to you, but all this is entirely new to me, so new that I don't even know how to pose the right questions.

                  M Offline
                  M Offline
                  Matt Cavanagh
                  wrote on last edited by
                  #15

                  Maybe im being silly but the simplest solution I can think of is to embed the silverlight in a HTML page which this javascript function: function redirect(url){ window.location=url; } and then call that JS from silverlight with "http://domain.com/file.exe".

                  Strive to be humble enough to take advice, and confident enough to do something about it.

                  F 1 Reply Last reply
                  0
                  • M Matt Cavanagh

                    Maybe im being silly but the simplest solution I can think of is to embed the silverlight in a HTML page which this javascript function: function redirect(url){ window.location=url; } and then call that JS from silverlight with "http://domain.com/file.exe".

                    Strive to be humble enough to take advice, and confident enough to do something about it.

                    F Offline
                    F Offline
                    fjparisIII
                    wrote on last edited by
                    #16

                    We've already got a fairly elaborate Silverlight app. So without refactoring the entire design, we have to work from Silverlight to HTML, not the other way around. I'm thinking of taking a rather crude approach: HtmlPage.PopupWindow, with the URI parameter to PopupWindow pointing at the HTML page that downloads the executable. If there's a more elegant solution someone could suggest (I'm sure there must be), I'd be grateful to receive it.

                    M 1 Reply Last reply
                    0
                    • F fjparisIII

                      We've already got a fairly elaborate Silverlight app. So without refactoring the entire design, we have to work from Silverlight to HTML, not the other way around. I'm thinking of taking a rather crude approach: HtmlPage.PopupWindow, with the URI parameter to PopupWindow pointing at the HTML page that downloads the executable. If there's a more elegant solution someone could suggest (I'm sure there must be), I'd be grateful to receive it.

                      M Offline
                      M Offline
                      Matt Cavanagh
                      wrote on last edited by
                      #17

                      Well, you can set the URI straight to the exe to popup the download window. Therefore skipping the extra HTML page.

                      Strive to be humble enough to take advice, and confident enough to do something about it.

                      F 1 Reply Last reply
                      0
                      • M Matt Cavanagh

                        Well, you can set the URI straight to the exe to popup the download window. Therefore skipping the extra HTML page.

                        Strive to be humble enough to take advice, and confident enough to do something about it.

                        F Offline
                        F Offline
                        fjparisIII
                        wrote on last edited by
                        #18

                        Sounds good.

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups