Ive added a file download fucntion to my grid, its works perfectly well on my local development machine, but when i upload it to a hosted server, it wont work ! nothing seems to happen. In development I get the file dialoge box open in the browser, yet on the live server I dont get that, just the spinning ajax icon
heres the column in my grid
I have this in client settings
and this javascript on the page
and finally, this is the server side code
can anyone see where im going wrong ?
heres the column in my grid
<
telerik:GridAttachmentColumn
MaxFileSize
=
"1048576"
EditFormHeaderTextFormat
=
"Download File:"
HeaderText
=
"Download"
AttachmentKeyFields
=
"AudioID"
FileNameTextField
=
"AudioPath"
DataTextField
=
"SongTitle"
UniqueName
=
"AttachmentColumn"
>
</
telerik:GridAttachmentColumn
>
I have this in client settings
<
ClientSettings
>
<
ClientEvents
OnCommand
=
"gridCommand"
/>
</
ClientSettings
>
function gridCommand(sender, args) {
if (args.get_commandName() == "DownloadAttachment") {
var manager = $find('<%= RadAjaxManager.GetCurrent(Page).ClientID %>');
manager.set_enableAJAX(false);
setTimeout(function () {
manager.set_enableAJAX(true);
}, 0);
}
}
protected void RadGridAudio_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.DownloadAttachmentCommandName)
{
e.Canceled = true;
GridDownloadAttachmentCommandEventArgs args = e as GridDownloadAttachmentCommandEventArgs;
string fileName = args.FileName;
long attachmentId = (int)args.AttachmentKeyValues["AudioID"];
BusinessLayer.RegistrationAudio audio = new RegistrationAudio();
audio = registrationManager.GetRegistrationAudio(attachmentId);
string filePath = audio.AudioPath.Substring(0, audio.AudioPath.LastIndexOf(@"\"));
string _DownloadableProductFileName = audio.FileName;
if (audio.AudioPath != null && audio.FileName != null)
{
System.IO.FileInfo FileName = new System.IO.FileInfo(filePath + "\\" + _DownloadableProductFileName);
FileStream myFile = new FileStream(filePath + "\\" + _DownloadableProductFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
try
{
if (FileName.Exists)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;attachment; filename=\"" + FileName.Name + "\"");
HttpContext.Current.Response.AddHeader("Content-Length", FileName.Length.ToString());
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.TransmitFile(FileName.FullName);
HttpContext.Current.Response.Flush();
}
else
{
throw new Exception("File not found");
}
}
catch (Exception ex)
{
HttpContext.Current.Response.ContentType = "text/plain";
HttpContext.Current.Response.Write(ex.Message);
}
finally
{
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
}
}
}