Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 交替行_C#_Asp.net Mvc 3_Webforms_Rdlc - Fatal编程技术网

C# 交替行

C# 交替行,c#,asp.net-mvc-3,webforms,rdlc,C#,Asp.net Mvc 3,Webforms,Rdlc,我一直在开发一个MVC3应用程序,最近的一个需求是它有两个动态生成的报告。因此,我添加了一个带有reportviewer和两个报表(.rdlc)的WebForm。但当我试图设置条件行填充时,例如 =IIf(RowNumber(Nothing) Mod 2, "Blue", "Red") // Won't acctually use those colors but you get the gist 但最终的背景仍然是白色的。 我在一个真正的blue webform应用程序中尝试了完全相同的we

我一直在开发一个MVC3应用程序,最近的一个需求是它有两个动态生成的报告。因此,我添加了一个带有reportviewer和两个报表(.rdlc)的WebForm。但当我试图设置条件行填充时,例如

=IIf(RowNumber(Nothing) Mod 2, "Blue", "Red") // Won't acctually use those colors but you get the gist
但最终的背景仍然是白色的。 我在一个真正的blue webform应用程序中尝试了完全相同的webform,并从那里正确地呈现了它。我检查了MVC项目是否包含Webforms testproject中使用的所有引用,并在“Global.asax.cs”中将.aspx和.rdlc添加到忽略的路由中

为什么是混合恐怖?
由于性能原因,我不能从客户端报告生成更改为服务器端报告生成,也不能使用其他/远程服务器,因为环境(是复数)缺少带宽和连接。我更希望不必只为reportviewer添加单独的应用程序池(同样是性能问题)

编辑1:

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 ....

编辑2:
添加代码是为了给我正在做的事情提供更好的上下文,但是当从Webforms项目中发布代码时,我猜ReportViewer会执行一些Global.asax并不特别喜欢的Blackmagic请求。但是,尽管我尽了最大的努力,我还没能找到那种魔力

我通过修改页面初始化成功地解决了这个问题

protected void Page_Init( object sender, EventArgs e ) {
    ...
    ReportViewer.LocalReport.SetBasePermissionsForSandboxAppDomain(new PermissionSet(PermissionState.Unrestricted));
    ...
}

感觉像是一个黑客,所以在接受这个答案之前,我会等待一两天

你能在上下文中发布更多代码吗?添加了一些上下文代码,但鉴于我已经设法从Webforms应用程序获得了报告的复写本。aspx的报告可以正确呈现,这看起来很奇怪(至少对我来说)问题将出现在Global.asax或某些引用冲突之外的任何地方
// 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. */
}
protected void Page_Init( object sender, EventArgs e ) {
    ...
    ReportViewer.LocalReport.SetBasePermissionsForSandboxAppDomain(new PermissionSet(PermissionState.Unrestricted));
    ...
}