Click here to Skip to main content
14,382,621 members
Rate this:
Please Sign up or sign in to vote.
See more:
I can't get reportviewer to work on aspx page that is part of MVC3 project.
Reportviewer connects fine to server and obtains parameters if needed. But body never shows the report (or any error) and export button is disabled.

Funny thing is that if I create exactly same page (besides inheritance) in ASP.NET project it works fine.
So my first thought was that it has something to do with web.config settings but even removing any references to reportviewer from it doesn't stop report from working on ASP so it looks like any of the handlers,httphandlers,buildproviders and assemblies are not "required" to make it work.(if you look on page source it throws Your browser does not support scripts...and The Report Viewer Web Control HTTP Handler has not been registered... nonsense regardles)

Here are relevant lines from web.config
<buildProviders>
   <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</buildProviders>

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>    
      <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </handlers>
  </system.webServer>

<system.web>   
    </pages>
    <compilation debug="true">
      <assemblies><add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
      </assemblies>

Here is page:
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Register assembly="Microsoft.ReportViewer.WebForms, 
Version=10.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a" 

namespace="Microsoft.Reporting.WebForms" 

tagprefix="rsweb" %>
<%@ Import Namespace = "MvcMusicStore.Reports" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>

    <script runat="server">
      
            private void Page_Load(object sender, System.EventArgs e)
            {
                if (!IsPostBack)
                {
                    string reportPath = "/Reports/Management Reports/Stock Report";

                    ReportServerConnection rsc = new ReportServerConnection();

                    this.ReportViewer1.ServerReport.ReportServerCredentials = rsc;
                    this.ReportViewer1.ServerReport.ReportPath = reportPath;
                    this.ReportViewer1.ServerReport.ReportServerUrl =
                       new Uri(("http://MyServerName/ReportServer"));

                    
                        this.ReportViewer1.ServerReport.Refresh();
                } 
            }
            
        </script>
        
        <form id="Form1" runat="server" width="800px" height="600px">
        <ajaxToolkit:ToolkitScriptManager ID="ScriptManager1"  runat="server" EnablePageMethods="true" EnableScriptGlobalization="true"

                                EnableScriptLocalization="true">          
        </ajaxToolkit:ToolkitScriptManager>
        <asp:Panel ID="Panel2" runat="server" Font-Size="12pt" 

        GroupingText="" Width="800px" Height="600px" BorderColor="Red" BorderWidth="1">
        start
        <rsweb:reportviewer ID="ReportViewer1"  runat="server" 

    SizeToReportContent="False" Width="800px" Height="600px"

    ZoomMode="FullPage" ProcessingMode="Remote" BackColor="White" AsyncRendering="true"

                    BorderStyle="Solid" Enabled="true" BorderColor="Green" BorderWidth="1px"></rsweb:reportviewer>end
        
        </asp:Panel>
        </form>

</body>
</html>

and connection class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.Reporting.WebForms;
using System.Net;
using System.Configuration;
using System.Security.Principal;

namespace MvcMusicStore.Reports
{
    [Serializable]
    public class ReportServerConnection : IReportServerConnection2
    {
        public Uri ReportServerUrl
        {
            get
            {
                string url = ConfigurationManager.AppSettings["ReportViewerPath"]; //http://localhost/ReportServer
                if (string.IsNullOrEmpty(url))
                    throw new Exception("Missing url from the Web.config file");
                return new Uri(url);
            }
        }
        public int Timeout
        {
            // set timeout to 60 seconds
            get { return 60000; }
        }

        public IEnumerable<Cookie> Cookies
        {
            // No custom cookies
            get { return null; }
        }
        public IEnumerable<string> Headers
        {
            // No custom headers
            get { return null; }
        }

        public GEMReportServerConnection()
        {
        }


        public WindowsIdentity ImpersonationUser
        {
            get { return null; }
        }

        public ICredentials NetworkCredentials
        {
            get
            {
                // return null will force the use of impersonation, 
                // otherwise, remove the return null and 
                // implement the other app settings to specify the credential details
                // return null;                

                string userName = ConfigurationManager.AppSettings["ReportViewerUser"];
                if (string.IsNullOrEmpty(userName))
                    throw new Exception("Missing user name from Web.config file");
                string password = ConfigurationManager.AppSettings["ReportViewerPassword"];
                if (string.IsNullOrEmpty(password))
                    throw new Exception("Missing password from Web.config file");
                string domain = ConfigurationManager.AppSettings["ReportViewerDomain"];
                if (string.IsNullOrEmpty(domain))
                    throw new Exception("Missing domain from Web.config file");
                return new NetworkCredential(userName, password, domain);
            }
        }

        public bool GetFormsCredentials(
         out Cookie authCookie,
         out string userName,
         out string password,
         out string authority)
        {
            authCookie = null;
            userName = null;
            password = null;
            authority = null;
            return false;
        }
    }
}

I'm guessing my ajax:ToolkitScriptManager works fine (is there a way to test it?). Any ideas?
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

<asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown">
EnablePartialRendering="false">
</asp:ScriptManager

>

http://social.msdn.microsoft.com/Forums/en-GB/vsreportcontrols/thread/6219309d-030d-4618-8580-4f534b7ba55d[^]
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100