locked
Download File from ASP.NET to Mobile Device always sends my *.aspx file instead of the specified filepath RRS feed

  • Question

  • User-267219661 posted
    I have read the forums extensively because I don't want to waste anyone's time. However, I am stuck and I have been unable to locate the answer from the forums.

    I want to download an executable file to either PocketPC or Palm. Thus, a portion of my code looks like the following:

                        this.Context.Response.Clear();
                        this.Context.Response.ContentType = "application/octet-stream";
                        this.Context.Response.AddHeader("Content-Disposition", "attachment; filename="+ filename );
                        this.Context.Response.AddHeader("Content-Length", fInfo.Length.ToString());
                        this.Context.Response.WriteFile(filepath);
                        this.Context.Response.End();

    I am using the PocketPC 2002 Emulator and the Palm OS Simulator for Treo 650.  The browsers for both emulators access my MobileWebForm1.aspx without issue, and both display the file size correctly.  However, both always display 'MobileWebForm1.aspx' as the file to download instead of the requested filename.  I have stepped through with the debugger and I know the filename and filepath are correct.  In fact, I used IE Browser on my laptop, and it worked as advertised.

    Questions:

    1. How do I get the emulators to display and download the correct filename?
    2. Are the emulators the problem?
    3. Does the file need to exist in the same directory as the ASP.NET files?
    4. How and why does the 'MobileWebForm1.aspx' file get selected for download?

    I appreciate any help on this issue.

    Jeff

    Sunday, September 4, 2005 8:50 PM

All replies

  • User-95607119 posted
    Use so called first-hit-approach. Instead of myfile.aspx use URL like myfile.aspx/download_file_name.jpg
    In this case myfile.aspx is called but device understands that filename is download_file_name.jpg
    Just make your download URL-s this way and give correct file name.

    By example, for cars.jpg you should have url myfile.aspx/cars.jpg. myfile.aspx is called and you
    make download there.

    I hope it helps.
    Monday, September 5, 2005 7:16 AM
  • User-267219661 posted
    Thanks for the reply, but unfortunately, that did not help. 

    I am starting to believe, hopefully erroneously, that PDA browsers do not support application file downloads.  I was hoping to download CAB files to the PocketPC and Nutshell install files to the Palm wirelessly, but so far I have not conjure up the answer I need.


    Monday, September 5, 2005 10:17 PM
  • User-2054111585 posted

    I got the same problem.

    I appreciate your help on this issue!

    Addie

    Wednesday, September 6, 2006 11:41 PM