This is the error:
The entry is not a valid Base 64 string, since contains a non-base 64 character, more than two characters of or an illegal character between fill-in.
This is my view, where I pass the parameters from my grid (table):
<td>
@Html.ActionLink("Download", "Download", new { item.ID_SOLIC_RELATORIO, item.POC_RELATORIO.NM_RELATORIO, item.BL_RELATORIO })
</td>
This is the method in my controller that receives the parameters:
public FileResult Download(int ID_SOLIC_RELATORIO, string NM_RELATORIO, byte[] BL_RELATORIO)
{
int _arquivoId = 1;
var arquivos = oModelFiles.GetFileReport(ID_SOLIC_RELATORIO, NM_RELATORIO, BL_RELATORIO);
string nomeArquivo = (from arquivo in arquivos
where arquivo.arquivoID == _arquivoId
select arquivo.arquivoCaminho).First().ToString();
string contentType = "application/pdf";
//Os parametros para o arquivo são
//1. o caminho do aruivo on servidor
//2. o tipo de conteudo do tipo MIME
//3. o parametro para o arquivos salvo pelo navegador
return File(nomeArquivo, contentType, "novoreport.pdf");
}
And this is my Model that receives values from the controller too:
public List<PDFFiles> GetFileReport(int _Id_Solic_Relat, string NM_RELATORIO, byte[] BL_RELATORIO)
{
//POC_SOLIC_RELATORIO relat = new POC_SOLIC_RELATORIO();
List<PDFFiles> lstFiles = new List<PDFFiles>();
//DirectoryInfo dirInfo = new DirectoryInfo(HostingEnvironment.MapPath("~/Arquivos"));
DirectoryInfo dirInfo = new DirectoryInfo("C:/Relatemp/");
string arquivoCaminho = string.Empty;
int i = 0;
foreach (var item in dirInfo.GetFiles())
{
lstFiles.Add(new PDFFiles()
{
arquivoID = _Id_Solic_Relat,
arquivoNome = NM_RELATORIO,
arquivoBinario = BL_RELATORIO,
arquivoCaminho = dirInfo.FullName + @"\" + item.Name
});
i = i + 1;
}
return lstFiles;
}
How do I resolve the error issue? I tried to give a Convert.FromBase64String()
, but this did not work, even moving the arguments to string
. How do I do this? How do I convert or remove the strange characters claimed in the error?
I took this #