[CLOSED] MVC DirectEvent Download File

  1. #1

    [CLOSED] MVC DirectEvent Download File

    Heya,

    I have a gridpanel with a commandcolumn.
    I attached a DirectEvent to the commandcolumn which calls an Action in my Controller.
    I want this Action to return a File for the user to download.

    Example of the Action:
    public ActionResult FileCommand(Guid fileid, string commandtype)
            {
                switch (commandtype)
                {
                    case "Delete":
                        return new JsonResult
                        {
                            Data = new { success = true }
                        };                    
                    case "Download":
                        return new FileContentResult(System.IO.File.ReadAllBytes(@"C:\testfile.pdf"), "application/pdf");                    
                }
                return new JsonResult
                {
                    Data = new { success = false }
                };
            }
    DirectMethod:
    DirectEvents(directevents =>
                                                        {
                                                            directevents.Command.Url = "FileCommand";
                                                            directevents.Command.FormID = "RollbackTab";
                                                            directevents.Command.IsUpload = true;                                                                   
                                                            directevents.Command.ExtraParams.Add(new Parameter("fileid", "record.data.Id", ParameterMode.Raw));
                                                            directevents.Command.ExtraParams.Add(new Parameter("commandtype", "command", ParameterMode.Raw));
                                                        }
    When calling this Action from a directevent I get the following Response:
    Click image for larger version. 

Name:	response.png 
Views:	30 
Size:	9.9 KB 
ID:	6236

    What am I doing wrong or how can I download a file from a directmethod?
    Last edited by Daniil; May 17, 2013 at 11:53 AM. Reason: [CLOSED]
  2. #2
    Hi @MWM2Dev,

    When calling this Action from a directevent I get the following Response
    Do you think it is a response? I think a request is just stopped due to a permission error.

    Is it specific to any browser? Is it reproducible in IE, Chrome, FireFox?
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @MWM2Dev,



    Do you think it is a response? I think a request is just stopped due to a permission error.

    Is it specific to any browser? Is it reproducible in IE, Chrome, FireFox?
    Hi Daniil,

    Thanks for the reply. The response wasnt the problem indeed

    After changing the Result to:
    return this.File(@"C:\testfile.pdf", "application/pdf", "testfile.pdf");
    it worked.

    Thanks for the reply!

Similar Threads

  1. 2.1 zip file download
    By gdog_5021 in forum 2.x Help
    Replies: 4
    Last Post: Dec 03, 2012, 11:14 AM
  2. [CLOSED] DirectEvent File Download plus MaskEdit issue
    By digitek in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jun 11, 2012, 2:08 PM
  3. [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
  4. [CLOSED] [1.0] DirectEvent File Download
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jan 21, 2011, 6:04 PM
  5. [CLOSED] [1.0] - MVC - DirectEvent Download File
    By drkoh in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 23, 2010, 8:26 PM

Posting Permissions