Duminda Dissanayake Ответов: 1

Интеграция сервера отчетов Sql 2008R2 с ASP.NET веб-приложение не работает


SQL 2008R2 SSRS report server работает в internet explore, но при вызове reportviewer с помощью Visual Studio 2010 ASP.net c# произошла следующая ошибка.

{"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)}


Что я уже пробовал:

<pre lang="ASP.NET">&lt;pre lang=&quot;ASP.NET&quot;&gt;&amp;lt;%@ Page Title=&amp;quot;&amp;quot; Language=&amp;quot;C#&amp;quot; MasterPageFile=&amp;quot;~/Site.Master&amp;quot; AutoEventWireup=&amp;quot;true&amp;quot; CodeBehind=&amp;quot;EmployeeCount.aspx.cs&amp;quot; Inherits=&amp;quot;WEB.EmployeeCount&amp;quot; %&amp;gt;

&amp;lt;%@ Register Assembly=&amp;quot;Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&amp;quot;
    Namespace=&amp;quot;Microsoft.Reporting.WebForms&amp;quot; TagPrefix=&amp;quot;rsweb&amp;quot; %&amp;gt;


&amp;lt;asp:Content ID=&amp;quot;Content2&amp;quot; ContentPlaceHolderID=&amp;quot;MainContent&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;
    &amp;lt;rsweb:ReportViewer ID=&amp;quot;ReportViewer1&amp;quot; runat=&amp;quot;server&amp;quot; ProcessingMode=&amp;quot;Remote&amp;quot;&amp;gt;
    &amp;lt;/rsweb:ReportViewer&amp;gt;
    &amp;lt;asp:ScriptManager ID=&amp;quot;ScriptManager1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;
    &amp;lt;/asp:ScriptManager&amp;gt;
&amp;lt;/asp:Content&amp;gt;&lt;/pre&gt;


&lt;pre lang=&quot;C#&quot;&gt;private void ShowReport()
        {
            try
            {


                ReportViewer1.ProcessingMode = ProcessingMode.Remote;

                ServerReport serverReport = ReportViewer1.ServerReport;
                serverReport.ReportServerUrl =
                    new Uri(&amp;quot;https://LKCSCAPP03.com:443&amp;quot;);

                


                // Set the report server URL and report path  
                serverReport.ReportPath =  &amp;quot;/Pages/Report.aspx?ItemPath=%2fPayrollReport%2fCompanyList&amp;quot;;

                IReportServerCredentials irsc = new CustomReportCredentials(&amp;quot;UserID&amp;quot;, &amp;quot;Password&amp;quot;, &amp;quot;Domain&amp;quot;);
                serverReport.ReportServerCredentials = irsc;


                
                ReportParameter reportParameterValue = new ReportParameter();
                serverReport.SetParameters(new ReportParameter[] { reportParameterValue });

                serverReport.Refresh();

                
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }&lt;/pre&gt;</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(&quot;advapi32.dll&quot;, 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
                {
                    // Use credentials from config file

                    IntPtr userToken = IntPtr.Zero;

                    bool success = LogonUser(
                      _UserName,
                      _DomainName,
                      _PassWord,
                      9,//LOGON_TYPE_NEW_CREDENTIALS
                      3,//LOGON32_PROVIDER_WINNT50
                      out userToken);

                    if (!success)
                    {
                        throw new Exception(&quot;Logon user failed&quot;);
                    }

                    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>

Duminda Dissanayake

Пожалуйста, помогите мне, как вызвать Сервер отчетов SSRS ASP.net использование Visual studio 2010. Контроллер управления не работает.

#realJSOP

Я думаю, вы хотели сказать, что "я делаю это неправильно".

1 Ответов

Рейтинг:
2

#realJSOP

Убедитесь, что ваш connectionstring правильно.