开发者

pdf render to asp.net web page results in static title

开发者 https://www.devze.com 2023-01-26 11:31 出处:网络
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:

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();

This works with no issues at all, however in order to render this pdf (ie. return the byte array) we are calling a web s开发者_运维知识库ervice 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.

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.

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.

Any help would be greatly appreciated,

Cheers,

Adam


Your headblock is being cleared by:

Response.ClearContent();

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

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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号