Hi I am trying to download file in mvc4. Below is my code to download the file. I am making ajax request to get file. My controller code looks like fine. variable result will get required bytes. I am having trouble with success gfunction in Download function in jquery. control will not come to success function. Even my alert is not working. Am i missing anything in the above code? Can someone please suggest me?
 public ActionResult Download(int? ClientId)
        {
            service.Service objService = new service.Service();
            DashboardBAL objdb = new DashboardBAL();
            string filepath = objdb.GetFilepath(ClientId.GetValueOrDefault(0));
            string folderName = @"F:\UploadedFile";
            string serverMappath = (folderName);
             byte[] result = objService.DownloadFileFromDMS(filepath);
            string contentType = MimeMapping.GetMimeMapping(filepath);
            string FileName = Path.GetFileName(filepath);
            var cd = new System.Net.Mime.ContentDisposition
            {
                FileName = Path.GetFileName(filepath),
                Inline = true,
            };
            if (!System.IO.Directory.Exists(serverMappath))
            {
                System.IO.Directory.CreateDirectory(serverMappath);
            }
            string strdocPath = serverMappath + @"\" + FileName;
            if (result != null)
            {
                FileStream objfilestream = new FileStream(strdocPath, FileMode.Create, FileAccess.Write);
                objfilestream.Write(result, 0, result.Length);
                objfilestream.Close();
            }
            return File(result, System.Net.Mime.MediaTypeNames.Application.Octet, FileName);
        }
function Download(pClientid) {
        $.ajax(
        {
            type: "GET",
            cache: false,
            data: { ClientId: pClientid },
            contentType: 'application/json; charset=utf-8',
            dataType: "json",
            cache: false,
            url: '@Url.Action("Download", "TestRendering")',
           // url: '/TestRendering/Download',
            headers: {
                'VerificationToken': forgeryId
            },
            success: function (data) {
                alert(1);
                ShowFiepopup(data);
            }
        });
    }
function ShowFiepopup(FileName) {
        $("#dialog").dialog({
            modal: true,
            title: "Preview of " + FileName,
            width: 850,
            height: 600,
            buttons: {
                Close: function () {
                    $(this).dialog('close');
                }
            },
            open: function () {
                var object = "<object data=\"{FileName}\" type=\"application/pdf\" Zoom=\"100%\" width=\"800px\" height=\"600px\">";
                object += "If you are unable to view file, you can download from <a href=\"{FileName}\">here</a>";
                object += " or download <a target = \"_blank\" href = \"http://get.adobe.com/reader/\">Adobe PDF Reader</a> to view the file.";
                object += "</object>";
                object = object.replace(/{FileName}/g, "../UploadedFile/" + FileName);
                $("#dialog").html(object);
            }
        });
    };
function Download(pClientid) {
        var fileUrl = '@Url.Action("Download", "TestRendering",new {ClientID= "pClientid" })';
        alert(fileUrl);
        fileUrl = fileUrl.replace("_X_", fileName);
        ShowFiepopup(fileUrl)
    }
 
    