Пользователь нажимает кнопку/действие - идет вызов Исходного кода. Там вылолняется работа и возвращает MemoryStream(это файл ПДФ)

Как теперь сделать чтобы этот файл или скачался или отобразился в новой странице?

Нравится

3 комментария
Лучший ответ

Как то так:

var response = System.Web.HttpContext.Current.Response;
	response.ClearContent();
	response.ContentType = "application/pdf";
	response.AddHeader("Content-Disposition", "inline; filename=" + docName);
	response.AddHeader("Content-Length", docStream.Size);
	response.BinaryWrite((byte[])docStream);
	response.End();

 

Как то так:

var response = System.Web.HttpContext.Current.Response;
	response.ClearContent();
	response.ContentType = "application/pdf";
	response.AddHeader("Content-Disposition", "inline; filename=" + docName);
	response.AddHeader("Content-Length", docStream.Size);
	response.BinaryWrite((byte[])docStream);
	response.End();

 

Григорий Чех,

Благодарю, вот в итоге рабочий код:

var response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.ContentType = "application/pdf";
response.AddHeader("Content-Disposition", "inline; filename=Ведомость расчетов с клиентом.pdf");
response.AddHeader("Content-Length", f.GetLongLength(0).ToString());
response.BinaryWrite(f);
response.End();

f - это тип byte[]

Рад что у вас получилось smiley

Показать все комментарии