1
That is the mistake:
The input is not a valid Base 64 character string, as contains a character that is not base 64, more than two characters from or an illegal character between the characters of filling up.
This is my view, where I pass the parameters coming 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 gets the values from the controller as well:
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 issue of error? I tried to give a Convert.FromBase64String()
, but this did not work, even passing the arguments to string
. How do I do this? How do I convert or remove the strange characters claimed in the error?
I got this link on the net, but I couldn’t resolve
Just one question: I should convert in the View, right? I don’t see anywhere else or not?
– pnet
You should in the VIEW have a link to the ACTION that responds in byteArray to the download, is doing right by the look, I just found it strange you pass the parameter 'BL_RELATORIO'
– PauloHDSousa
@Paulohdsousa, dude what I saw now that he created the file with the extension. pdf, but it’s actually a .doc. In word it opens without problems and the data is all there. now is that I don’t know where it came from the . doc.
– pnet
What file name? Maybe it doesn’t come from him?
– PauloHDSousa
I saw that I don’t need the byte[]. Even without Camo BL_RELATORIO I can record something. The problem that this approach as it is, does not suit me, because anyway it is dependent on files in the folder and should not be so. I will use another approach or open another post if I can’t and explain better what I want.
– pnet