May 17, 2013, 10:33 AM
[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:
What am I doing wrong or how can I download a file from a directmethod?
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: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]