[CLOSED] [1.0] File download in MVC

  1. #1

    [CLOSED] [1.0] File download in MVC

    Hi,

    I try to do a file download, but I always receive "Request Error".

    Here is my button definition:

    <ext:Button runat="server" Text="Click Me">
                <DirectEvents>
                    <Click Url="~/Home/OnClicked" IsUpload="true" />
                </DirectEvents>
            </ext:Button>
    and the controller method is equally simple:

    public ActionResult OnClicked()
            {
                return new FileContentResult( Encoding.UTF8.GetBytes( "testing" ), MediaTypeNames.Text.Plain );
            }
    Is it supported?


    Thanks,
    Tadeusz
  2. #2

    RE: [CLOSED] [1.0] File download in MVC

    Hi,

    IsUpload works if from presented only. Therefore you should wrap the button by form
    <form>
        <ext:Button runat="server" Text="Click Me">
                <DirectEvents>
                    <Click Url="/Data/OnClicked" IsUpload="true" />
                </DirectEvents>
        </ext:Button>
    </form>
    It works fine for FF and Chrome but IE as always works differently. It still try to open content in the page (instead to show save file dialog) therefore it is need to use none-standard content-type
    public ActionResult OnClicked()
            {
                return new FileContentResult(Encoding.UTF8.GetBytes("testing"), "text/text");
            }
  3. #3

    RE: [CLOSED] [1.0] File download in MVC

    Thanks a lot!

    Regards,
    Tadeusz

Similar Threads

  1. [CLOSED] How to download a file in DirectEvent?
    By vadym.f in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jun 08, 2012, 1:20 PM
  2. [CLOSED] [1.0] MVC Download file
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 02, 2010, 11:10 AM
  3. [CLOSED] Download a file in an MVC app
    By Stefanaccio in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 02, 2010, 9:01 PM
  4. [CLOSED] File download from AjaxEvent
    By tdracz in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 02, 2009, 8:02 AM
  5. File download
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 05, 2008, 7:22 AM

Posting Permissions