PDF渲染到静态标题asp.net网页结果

问题描述:

,使用下面的code:

having a slight issue where i am rendering a pdf (stored as a byte array) into an asp.net web page, using the code below:

Response.ClearContent();
Response.AppendHeader("content-length", document.Length.ToString());
Response.ContentType = "application/pdf";
Response.BinaryWrite(document);
Response.Flush();
Response.Close();

这适用于完全没有问题,但为了使这个PDF格式(即返回字节数组),我们通过在查询字符串传递一些参数调用Web服务。这就是问题的用武之地。一旦PDF呈现,它显示的标题页的完整URL +查询字符串。显然,出于安全原因,我们不希望用户获取该信息的保留。

This works with no issues at all, however in order to render this pdf (ie. return the byte array) we are calling a web service by passing a few parameters in the QueryString. This is where the issue comes in. Once the PDF renders, it shows the title as the complete url + query string of the page. obviously, for security reasons we dont want users getting a hold of that information.

没有人知道如何设置页面的标题,一旦PDF呈现出来?我试图使头运行服务器端,但它没有任何影响。有趣的是,如果PDF渲染失败,或者一个数据的方法,它正确地将标题手之前失败。它几乎像一旦它击中PDF呈现它改变了标题回到URL /查询字符串。

does anyone know how to set the title of the page once the pdf renders out? i have tried making the header run server side, however it doesnt have any effect. interestingly, if the pdf render fails, or a data method fails before hand it changes the title correctly. its almost like once it hits the pdf rendering it changes the title back to the url/querystring.

除了这个,我还检查了由Web服务并存储在PDF属性标题传递回来的PDF的标题是呈现在页面的标题栏标题完全不同。

in addition to this, i also checked the title of the PDF that was passed back by the web service and the title stored in the PDF properties is completely different to the title rendered on the title bar of the page.

任何帮助将大大AP preciated,结果
干杯,结果
亚当

Any help would be greatly appreciated,
Cheers,
Adam

您制动轮正在被清除:

Response.ClearContent();

所以,即使你设置它在<标题> ...< /标题方式> ,你永远发送该给客户端

So even if you're setting it in <title>...</title>, you're never sending that to the client.

由于内容类型为应用程序/ PDF 的浏览器不知道如何渲染的标题,所以它呈现的URL。

Given the content type is application/pdf the browser doesn't know how to render the title, so it renders the URL.

朦胧不是安全的一种形式,如果你是依靠用户无法从重新下载文件知道具体的URL,以prevent他们,你需要重新思考。随着网络检测工具,他们将能够轻松地看到他们请求的资源,即使你混淆的网址。

Obscurity isn't a form of security, and if you're relying on the user not knowing the Url to prevent them from downloading the file again, you need to rethink. With a network inspection tool they'll easily be able to see which resources they're requesting, even if you do obfuscate the Url.