I want to have my pdf files sent this way to my users :
public ActionResult GetPDF( string filename )
{
return File( filename, "application/pdf", Server.HtmlEncode( filename ) );
}
But I don't know how to create a route that will catch all the different pdf file in my site?
Thanks a lot for the help开发者_如何学JAVA!
Try this..
string FilePath = MapPath("your.pdf");
Response.ContentType = "Application/pdf";
Response.AppendHeader( "content-disposition", "attachment; filename=" + FilePath);
Response.WriteFile(FilePath);
Response.End();
EDIT:
Oups just saw it's MVC...
Try to append the header anyway before returning...
I found a way to do what I was trying to do just read this link : http://forums.iis.net/t/1162518.aspx or this one http://dotnetslackers.com/articles/aspnet/Range-Specific-Requests-in-ASP-NET.aspx
It's not by routing but with a Handler in IIS.
If someone has a better solution, please, let me know :)
EDIT :
It's realy not working great, you can take a look here : http://www.ville.st-augustin.qc.ca/carte-interactive click on "carte de zonage" tab and then on any adobe icon and it's not working as it should be... any help appreciated!
精彩评论