Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to display SSRS reports in MHTML format, the report is embeded with image, in development server the image is displaying in the report , but in prodution server its not displaying , can anybody please help me to resolve this issue. i am displaying report in HTML and PDF format, In Pdf format the report is working fine both in development and production server, but In HTML format the image in the report is working fine in development server when i published and deployed to the production server the Image in the report is not displaying. The report format Given is MHTML. If i access the application from production using URL the image is displaying in my machine, but in others machine its not displaying. I checked with the IE version, in other system also the IE version is same.If i save the report and allow the activex then its showing the image in report in all systems, if i directly open the report instead of saving the image is not displaying.

The code is

public void ProcessRequest(HttpContext context)
      {
          try
          {
       ReportExecutionService rs = new ReportExecutionService();

              string empid= 1;
              string reportName = System.Configuration.ConfigurationManager.AppSettings["quoteReportDirectory"];


              if (context.Request.QueryString["Format"] == null)
              {
                  throw new Exception("Required parameter Format not supplied");
              }
              string format = context.Request.QueryString["Format"];


              ExecutionInfo ei = rs.LoadReport(reportName, null);
              List<parametervalue> parameters = new List<parametervalue>();
              foreach (ReportParameter rp in ei.Parameters)
              {
                  string val = context.Request.QueryString[rp.Name];
                  if (val == null)
                  {
                      throw new Exception("required parameter " + rp.Name + " not supplied");
                  }
                  ParameterValue pv = new ParameterValue();
                  pv.Name = rp.Name;
                  pv.Value = val;
                  parameters.Add(pv);
              }


              string extension = string.Empty;
              string mimeType = string.Empty;
              string encoding = string.Empty;
              Warning[] warnings = null;
              string[] streamIds = null;



              rs.SetExecutionParameters(parameters.ToArray(), "en-us");


              byte[] content = rs.Render(format, null, out extension, out mimeType, out encoding,
                                              out warnings, out streamIds);


              context.Response.ContentType = mimeType;


              if (format == "PDF")
              {
                  context.Response.AppendHeader("Content-Disposition", "attachment; " + "filename=" + quoteId + ".pdf");
              }
              else if (format == "MHTML")
              {
                  context.Response.AppendHeader("Content-Disposition", "attachment; " + "filename=" + quoteId + ".mhtml");
              }


              context.Response.OutputStream.Write(content, 0, content.Length);
              context.Response.OutputStream.Flush();
          }
          catch (Exception e)
          {
              Logger.log("Reporting error", e);
          }
          finally
          {
          }
      }


Thank you.
Posted
Updated 1-Feb-12 1:12am
v3
Comments
Rajesh Anuhya 1-Feb-12 6:38am    
Code tags added

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900