I’ve been working on an MVC3 app and a recent requirement is that it has a couple of dynamically generated reports. So I added a single webbform with a reportviewer and a couple of reports (.rdlc). But when I try to set Conditional row-fills eg
=IIf(RowNumber(Nothing) Mod 2, "Blue", "Red") // Won't acctually use those colors but you get the gist
But the resulting background is still white.
I tried out the exact same webform in a true blue Webform application and from there it rendered properly. I’ve checked that my MVC project contains every reference used in my Webforms testproject and added .aspx and .rdlc to ignored routes in ‘Global.asax.cs’.
Why the Hybrid Horror?
I can not change from Clientside Reporting generation to Serverside due to Performance Reasons, nor can I use a different/remote server because the environments (yes plural) lack of bandwidth and connectivity. And I’d prefer not having to add a separate app pool just for the reportviewer (again performance issues).
EDIT1:
Global.asax
public class MvcApplication : System.Web.HttpApplication {
public static void RegisterGlobalFilters ( GlobalFilterCollection filters ) {
filters.Add(new HandleErrorAttribute());
}
public static void RegisterRoutes ( RouteCollection routes ) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.IgnoreRoute("{resource}.rdlc/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_Start () {
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
}
Report.aspx
….
</rsweb:ReportViewer>
<asp:XmlDataSource ID="reportsDS" runat="server"
DataFile="~/Reporting/ReportSettings/Reportlist.xml"
XPath="Reports/Report" />
<asp:ScriptManager ID="scriptmanager" runat="server" />
....
Report.aspx.cs
// Some configuration initialization and the regular Page_Init + Page_Load assigning
// default values
protected void changeReport() {
ReportViewer.Reset();
ReportDataSource RDS = new ReportDataSource( /* grabbed from a combination of applicationsettings and input parameters */
ReportViewer.LocalReport./* adding datasource and setting paths, names, etc. */
}
EDIT2:
Added the code to give better context to what I’m doing but seeing that the Code acctually works when published from a Webforms project I’m guessing that ReportViewer performs some sort of Blackmagic requests that the Global.asax isn’t particularly fond of. But despite my best firebug efforts I haven’t been able to find that brand of magic yet.
I managed to solve the problem by modifying the Page_Init
Feels like a hack, so I’ll hold of a day or two before accepting this answer