public ActionResult ProductCatalogs(string writerFormat) { try { string fileName = null; WriterFormat format; HttpContext httpContext = System.Web.HttpContext.Current; ReportWriter reportWriter = new ReportWriter(); reportWriter.ReportProcessingMode = ProcessingMode.Local; reportWriter.ReportPath = Server.MapPath("~/App_Data/Reports/Product Catalog.rdlc"); reportWriter.DataSources.Clear(); reportWriter.DataSources.Add(new ReportDataSource { Name = "ProductCatalog", Value = ProductCatalog.GetData() }); if (writerFormat == "PDF") { fileName = "Product Catalog.pdf"; format = WriterFormat.PDF; } else if (writerFormat == "Word") { fileName = "Product Catalog.doc"; format = WriterFormat.Word; } else if (writerFormat == "Html") { fileName = "Product Catalog.Html"; format = WriterFormat.HTML; } else { fileName = "Product Catalog.xls"; format = WriterFormat.Excel; } reportWriter.Save(fileName, format, httpContext.Response); } catch { } return(View()); }