This may be useful for those who are facing this problem. I finally understood the solution. It turns out that even if we use inline for "content-disposition" and specify the file name, browsers still do not use the file name. Instead, browsers try to interpret the file name based on the path / URL.
You can read further at this URL: Secret download of a file inside the browser with the correct file name
This gave me an idea, I just created my URL, which translates the URL and ends with the name of the file I would like to provide. So, for example, my initial call to the controller was only to pass the order identifier of the printed order. I expected the file name to be in the format Order {0} .pdf, where {0} is the order identifier. Similarly, for quotes, I need Quote {0} .pdf.
In my controller, I just went ahead and added an extra parameter to accept the file name. I passed the file name as a parameter in the URL.Action method.
Then I created a new route that would map this URL into the format: http: //localhost/ShoppingCart/PrintQuote/1054/Quote1054.pdf
routes.MapRoute("", "{controller}/{action}/{orderId}/{fileName}", new { controller = "ShoppingCart", action = "PrintQuote" } , new string[] { "xxxControllers" } );
routes.MapRoute("", "{controller}/{action}/{orderId}/{fileName}", new { controller = "ShoppingCart", action = "PrintQuote" } , new string[] { "xxxControllers" } );
This pretty much solved my problem. Hope this helps someone!
Cheerz, Anup
Anup Marwadi Jul 15 '10 at 5:16 2010-07-15 05:16
source share