Click here to Skip to main content
15,124,736 members
Please Sign up or sign in to vote.
4.00/5 (1 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
   <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

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

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

Here is page:
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Register assembly="Microsoft.ReportViewer.WebForms, 
Version=, Culture=neutral, 
tagprefix="rsweb" %>
<%@ Import Namespace = "MvcMusicStore.Reports" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">

    <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"));

        <form id="Form1" runat="server" width="800px" height="600px">
        <ajaxToolkit:ToolkitScriptManager ID="ScriptManager1"  runat="server" EnablePageMethods="true" EnableScriptGlobalization="true"
        <asp:Panel ID="Panel2" runat="server" Font-Size="12pt" 
        GroupingText="" Width="800px" Height="600px" BorderColor="Red" BorderWidth="1">
        <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


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
    public class ReportServerConnection : IReportServerConnection2
        public Uri ReportServerUrl
                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
                // 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?

1 solution

<asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown">


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