Programming Solutions

Your Source for Information

InvalidOperationException: Client found response content type of ‘’, but expected ‘text/xml’. The request failed with an empty response.

by Maeenul 4. January 2011 09:04

InvalidOperationException Client found response content type of '', but expected 'text/xml'. The request failed with an empty response. This is the error I was getting while working with reportviewer control in asp.net site. Let me explain the scenario. I had a template .rdl file. By template .rdl, I mean that I had a sample rdl file but this is not my final report definition xml. I changed the xml according to my needs to develop a dynamic report. After that I created a memory stream taking the bytes of the rdl file. Then I setup the ReportServerUrl and ReportServerCredentials of the ReportViewer control. After than I loaded the memory stream using LoadReportDefintion function. The code snippet looks like the following:

XmlDocument xmlDoc = newXmlDocument();

xmlDoc.Load(@"D:\Reporting Service\ReportViewerWithWebApplication\Report Project1\Report3.rdl");

xmlDoc.GetElementsByTagName("DataSourceReference")[0].InnerText = "/Data/DataSource2";

 

XmlNamespaceManager nsmgr = newXmlNamespaceManager(xmlDoc.NameTable);

nsmgr.AddNamespace("ns", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition");

 

AdjustTablixHierarchy(xmlDoc, nsmgr, "TablixRowHierarchy", rowElements, false);

AdjustTablixHierarchy(xmlDoc, nsmgr, "TablixColumnHierarchy", columnElements, true);

 

AdjustTablixCornerRows(xmlDoc, nsmgr);

 

AdjustTablixColumns(xmlDoc, nsmgr);

AdjustTablixRows(xmlDoc, nsmgr);

 

AdjustDataSetFields(xmlDoc, nsmgr);

 

byte[] rdlBytes = Encoding.UTF8.GetBytes(xmlDoc.OuterXml);

MemoryStream stream = newMemoryStream(rdlBytes);

ReportViewer1.ServerReport.ReportServerUrl = newUri(@"http://162.44.191.22:8080/reportserver");

ReportViewer1.ServerReport.ReportServerCredentials = new MyReportServerCredentials();

ReportViewer1.ServerReport.LoadReportDefinition(stream);

 

I was getting this error on the last line where I tried to load the report definition. Very confusing. But the problem was solved very simply. I checkef the sql server reporting service from windows services. It was running. In fact I had a problem in my report server web.config file. I resolved that problem and restarted IIS. The error message was gone. So, to conclude, if you have any problem with your report server web.config file that is located in "C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER2008\Reporting Services\ReportServer", you may get this error message. Just fix the problem and restart IIS, the error should be resolved.

Tags: , ,

Category: Asp.Net



Add comment

biuquote
  • Comment
  • Preview
Loading

Alpha Tags