Download PDF file by link in email

2

I developed a function that passing the Item id it generates a PDF file.

[HttpPut]
public void GerarPDF(long idItem)
{
....Função
}

It already works perfectly, I did the test through the Google Chrome app called PostMan, and passing the path it generates the PDF and downloads everything correctly, however if I send this same path in the body of an email through a <a></a> so that the person who received the email can generate the PDF, this path does not work:

"<a href=http://localhost:11599/Item/GerarPDF?idItem=" + IdItem.ToString() + "> link Download PDF </a>"

Giving the following error:

Now I do not know if it is because it is trying to open by localhost or not, if anyone can help me, I thank you.

    
asked by anonymous 22.03.2017 / 15:40

2 answers

1

I use this way to download.

public FileResult DownloadAnexo(int id)
{
    string URL = //BUSCAR URL ARQUIVO DESEJADO;
    return File(URL, "multipart/mixed", "Nome_SeuArquivo");
}

Note that the return is a FileResult

    
22.03.2017 / 15:52
5

An anchor ( <a href ...> ) will always send a GET to the server.

This is the problem, action is responding to requests PUT and not GET .

Just changing the attribute from [HttpPut] to [HttpGet] will already cause the action to be called.

[HttpGet]
public void GerarPDF(long idItem)
{
}
    
22.03.2017 / 16:02