Crystalreportviewer无法渲染(asp.net mvc4 razor语法) [英] Crystalreportviewer not rendering (asp.net mvc4 razor syntax)

查看:42
本文介绍了Crystalreportviewer无法渲染(asp.net mvc4 razor语法)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在visual studio 2012中使用asp.net mvc4(razor语法)创建一个水晶报告。我在网上看到一些文章,有两种方法可以通过剃刀视图实现这一点。



1:没有crystalreportviewer的简单pdf渲染

2:创建aspx页面并加载crystalreportviewer。



我要使用第二种方法创建一个aspx页面,在我的控制器中,我有以下代码。



Controller.cs

I'm trying to create a crystal report in asp.net mvc4 (razor syntax) in visual studio 2012. I read some articles on web that there are two ways of achieving this with razor views.

1: The simple pdf rendering without the crystalreportviewer
2: create aspx page and load crystalreportviewer on that.

I'm going with the second method where I've create an aspx page and in my controller, I have the following code.

Controller.cs

if (this.HttpContext != null && this.HttpContext.Session != null)
{
    this.HttpContext.Session["ReportName"] = "AccountStatement.rpt";
    this.HttpContext.Session["rptSource"] = reportInfo;
}
// Redirecting generic report viewer page from action
Response.Redirect("~/AspForms/aspnetgeneric.aspx")





在aspnetgeneric.aspx页面加载的代码隐藏中,我有:





In codebehind of aspnetgeneric.aspx page load, I have:

string strReportName = System.Web.HttpContext.Current.Session["ReportName"].ToString();
                ReportDocument rd = new ReportDocument();
                 
                    string strRptPath = Path.Combine(Server.MapPath("~/Reports"), strReportName);
                    rd.Load(strRptPath);

                    if (source.GetType().ToString() != "System.String")
                        rd.SetDataSource(source);
                    CrystalReportViewer1.ReportSource = rd;





代码在运行时没有任何异常运行正常,但没有显示crystalreportviewer或报告本身在浏览器窗口中。 (在所有主流浏览器上测试过)。我尝试将目标框架从4.5更改为4.0但仍然相同。

我可能缺少什么?任何线索?



Code runs fine without any exceptions on runtime but does not show the crystalreportviewer or the report itself in the browser window. (Tested on all major browsers). I tried changing the target framework to 4.0 from 4.5 but still the same.
What may i be missing? Any clues?

推荐答案

您可以在Chrome中的网络选项卡中看到错误。



渲染MVC中的报表查看器您的aspx页面必须托管在同一个域中才能使其可访问或服务器相同。



而不是重定向在MVC局部视图中显示页面。< br $>


问候,

Santosh
You can see the error in Network tab in chrome.

To render the report viewer in MVC your aspx page must be hosted in same domain to make it accessible or same server.

Also rather than redirect display your page in MVC partial view.

Regards,
Santosh


这篇关于Crystalreportviewer无法渲染(asp.net mvc4 razor语法)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆