Я не хочу, чтобы пользователь просто мог введите URL-адрес и получите файл PDF (например, http://MySite/MyPDFFolder/MyPDF.pdf)
Я хочу разрешить их просмотр только при загрузке их и отображать.
Я делал нечто подобное раньше. Я использовал PDFSharp, чтобы создать PDF-файл в памяти, а затем загрузить его на следующую страницу:
Код: Выделить всё
protected void Page_Load(object sender, EventArgs e)
{
try
{
MemoryStream streamDoc = BarcodeReport.GetPDFReport(ID, false);
// Set the ContentType to pdf, add a header for the length
// and write the contents of the memorystream to the response
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", Convert.ToString(streamDoc.Length));
Response.BinaryWrite(streamDoc.ToArray());
//End the response
Response.End();
streamDoc.Close();
}
catch (NullReferenceException)
{
Communication.Logout();
}
}
Мне также нужен способ сказать, что путь «/MyPDFFolder» недоступен для просмотра.
Спасибо. по любым предложениям
Подробнее здесь: https://stackoverflow.com/questions/122 ... -a-website
Мобильная версия