Saturday, January 15, 2011

Simple way to return pdf from an Action

Is it very easy to return a pdf file from server in Asp.net MVC:


// controller(Basket) code =

public ActionResult GetTradingCondition()
{
HttpContext.Response.AddHeader("content-disposition", " inline; filename=" + "TradingCondition.pdf");
return File(Server.MapPath("~/Content/Files/TradingCondition.pdf"), "application/pdf","TradingCondition.pdf");
}


// view code
<% =Html.ActionLink("Trading_conditions", "GetTradingCondition", "Basket",new{@target="_blank"})%>



=========================================

No comments:

Post a Comment

5 Strategies for Getting More Work Done in Less Time

Summary.    You’ve got more to do than could possibly get done with your current work style. You’ve prioritized. You’ve planned. You’ve dele...