SQL 2008R2 SSRS report server working on internet explore but when it calling reportviewer using Visual Studio 2010 ASP.net C# following error occurred.
{"The attempt to connect to the report server failed. Check your connection information and that the report server is a compatible version."}
[Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.MissingEndpointException]: {"The attempt to connect to the report server failed. Check your connection information and that the report server is a compatible version."}
Data: {System.Collections.ListDictionaryInternal}
HelpLink: null
HResult: -2146233088
InnerException: {"The request failed with HTTP status 404: Not Found."}
Message: "The attempt to connect to the report server failed. Check your connection information and that the report server is a compatible version."
Source: "Microsoft.ReportViewer.WebForms"
StackTrace: " at Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.MissingEndpointException.ThrowIfEndpointMissing(WebException e)\r\n at Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.ProxyMethodInvocation.Execute[TReturn](RSExecutionConnection connection, ProxyMethod`1 initialMethod, ProxyMethod`1 retryMethod)\r\n at Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.LoadReport(String Report, String HistoryID)\r\n at Microsoft.Reporting.WebForms.ServerReport.EnsureExecutionSession()\r\n at Microsoft.Reporting.WebForms.ServerReport.SetParameters(IEnumerable`1 parameters)\r\n at WEB.EmployeeCount.ShowReport() in Apppath/unt.aspx.cs:line 162"
TargetSite: {Void ThrowIfEndpointMissing(System.Net.WebException)}
What I have tried:
<pre lang="ASP.NET"><pre lang="ASP.NET">&lt;%@ Page Title=&quot;&quot; Language=&quot;C#&quot; MasterPageFile=&quot;~/Site.Master&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;EmployeeCount.aspx.cs&quot; Inherits=&quot;WEB.EmployeeCount&quot; %&gt;
&lt;%@ Register Assembly=&quot;Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot;
Namespace=&quot;Microsoft.Reporting.WebForms&quot; TagPrefix=&quot;rsweb&quot; %&gt;
&lt;asp:Content ID=&quot;Content2&quot; ContentPlaceHolderID=&quot;MainContent&quot; runat=&quot;server&quot;&gt;
&lt;rsweb:ReportViewer ID=&quot;ReportViewer1&quot; runat=&quot;server&quot; ProcessingMode=&quot;Remote&quot;&gt;
&lt;/rsweb:ReportViewer&gt;
&lt;asp:ScriptManager ID=&quot;ScriptManager1&quot; runat=&quot;server&quot;&gt;
&lt;/asp:ScriptManager&gt;
&lt;/asp:Content&gt;</pre>
<pre lang="C#">private void ShowReport()
{
try
{
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ServerReport serverReport = ReportViewer1.ServerReport;
serverReport.ReportServerUrl =
new Uri(&quot;https:
serverReport.ReportPath = &quot;/Pages/Report.aspx?ItemPath=%2fPayrollReport%2fCompanyList&quot;;
IReportServerCredentials irsc = new CustomReportCredentials(&quot;UserID&quot;, &quot;Password&quot;, &quot;Domain&quot;);
serverReport.ReportServerCredentials = irsc;
ReportParameter reportParameterValue = new ReportParameter();
serverReport.SetParameters(new ReportParameter[] { reportParameterValue });
serverReport.Refresh();
}
catch (Exception ex)
{
throw ex;
}
}</pre></pre>
<pre lang="C#">public class CustomReportCredentials : IReportServerCredentials
{
private string _UserName;
private string _PassWord;
private string _DomainName;
public CustomReportCredentials(string UserName, string PassWord, string DomainName)
{
_UserName = UserName;
_PassWord = PassWord;
_DomainName = DomainName;
}
[System.Runtime.InteropServices.DllImport("advapi32.dll", SetLastError = true)]
public static extern bool LogonUser(
string lpszUsername,
string lpszDomain,
string lpszPassword,
int dwLogonType,
int dwLogonProvider,
out IntPtr phToken);
public System.Security.Principal.WindowsIdentity ImpersonationUser
{
get
{
IntPtr userToken = IntPtr.Zero;
bool success = LogonUser(
_UserName,
_DomainName,
_PassWord,
9,
3,
out userToken);
if (!success)
{
throw new Exception("Logon user failed");
}
return new WindowsIdentity(userToken);
}
}
public ICredentials NetworkCredentials
{
get { return new NetworkCredential(_UserName, _PassWord, _DomainName); }
}
public bool GetFormsCredentials(out Cookie authCookie, out string user,
out string password, out string authority)
{
authCookie = null;
user = password = authority = null;
return false;
}
}</pre>