Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在WCF Rest服务中从数据库返回PDF_C#_Sql Server_Wcf Rest - Fatal编程技术网

C# 如何在WCF Rest服务中从数据库返回PDF

C# 如何在WCF Rest服务中从数据库返回PDF,c#,sql-server,wcf-rest,C#,Sql Server,Wcf Rest,我正在使用C#执行WCF-REST服务,它与SQL Server中的数据库连接以返回多个表。现在,我需要我的服务在varbinary(MAX)字段中返回一个存储在表中的PDF文件。我正在做一些研究,但我找不到我需要的东西。如何实现服务和类以返回PDF文件?谢谢1)编写一个返回流的方法(例如,一个保存pdf文件的MemoryStream) 从那个方法回来之前 2)将application/pdf设置为WebOperationContext.Current.OutgoingResponse.Cont

我正在使用C#执行WCF-REST服务,它与SQL Server中的数据库连接以返回多个表。现在,我需要我的服务在varbinary(MAX)字段中返回一个存储在表中的PDF文件。我正在做一些研究,但我找不到我需要的东西。如何实现服务和类以返回PDF文件?谢谢

1)编写一个返回
流的方法(例如,一个保存pdf文件的MemoryStream)

从那个方法回来之前

2)
application/pdf
设置为
WebOperationContext.Current.OutgoingResponse.ContentType

3)将长度设置为
WebOperationContext.Current.OutgoingResponse.ContentLength

然后它应该可以工作。

1)编写一个返回
流的方法(例如,一个保存pdf文件的MemoryStream)

从那个方法回来之前

2)
application/pdf
设置为
WebOperationContext.Current.OutgoingResponse.ContentType

3)将长度设置为
WebOperationContext.Current.OutgoingResponse.ContentLength


然后它就可以工作了。

Duplicate-Duplicate如何设置pdf名称?@anhtv13
WebOperationContext.Current.OutgoingResponse.Headers.Add(“内容处置:附件;文件名=\”+文件名+\”)如何设置pdf名称?@anhtv13
WebOperationContext.Current.OutgoingResponse.Headers.Add(“内容处置:附件;文件名=\”“+文件名+\”)