Page title and filename not working for PDF viewer from file handler

Viewed 338

I'm unable to get the Filename and Page title for my pdf viewer using asp.net handler.

I've added the required header for HTTPS Response, still no luck.

HttpContext.Current.Response.AddHeader("content-disposition", "inline; filename=\"" + fileName + "\"");
HttpContext.Current.Response.ContentType = "application/pdf";

I'm getting enter image description here

Response Header is as below

enter image description here

I'm Expecting below

enter image description here

It would be a great help if someone provides a valid solution. Thanks.

1 Answers

It's pulling that ShowHandler.aspx from the last segment of the url. If this is set up as an IHttpHandler and defined in the system.webServer/handlers section of the web.config, you can add a wildcard in the web.config. For example, if you have <add name="ShowHandler" path="ImageHandler/ShowHandler.ashx" then you can change it to <add name="ShowHandler" path="ImageHandler/ShowHandler.ashx/*" and change your url to http://localhost:444/ImageHandler/ShowHandler.ashx/PowerPoint%20Presentation

That will make the last segment of the url "PowerPoint Presentation", so that will be the title of the page.

Related