首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MVC4报告报告(&A)

MVC4报告报告(&A)
EN

Stack Overflow用户
提问于 2013-06-10 19:39:17
回答 1查看 692关注 0票数 1

我有一个MVC4应用程序,我还有一些报告托管在Azure报告服务上。我知道报表查看器不能直接在MVC Razor页面中工作,我见过带有报表查看器的aspx页面的示例。

然而,我无法让任何示例工作,或者它们是不完整的,或者不支持回发等。

有没有使用Azure报告的完整示例?我正在使用一个iFrame链接到天蓝色的报告,但这是不好的,因为用户需要登录到天蓝色的网站。

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-06-10 19:58:06

我以前是这样的,这对我来说很好。您可以下载示例项目来探索:) Sample Project for Azure + SSRS + MVC4

代码语言:javascript
复制
DataSourceCredentials cred = new DataSourceCredentials();
cred.Name = "DataSource1";
cred.UserId = "YourSQLServerLogin"; // this is the UserID which you used to Connect SQL
cred.Password = "YourSQLServerPassword";
ReportViewer1.ShowParameterPrompts = false;
ReportViewer1.ShowCredentialPrompts = false;
if(!this.IsPostBack) // make Sure you add this, or else Reporting will go in infinite loop. 
{
  try
  {
      ReportViewer1.ServerReport.ReportServerUrl = 
        new Uri(ConfigurationManager.AppSettings["SERVER_NAME"]);
      ReportViewer1.ServerReport.ReportPath = 
        ConfigurationManager.AppSettings["REPORT_PATH"];

      ReportViewer1.ServerReport.ReportServerCredentials = new ReportCredential();
      ReportViewer1.ServerReport.SetDataSourceCredentials(new DataSourceCredentials[] { cred });
  }
  catch (Exception ex)
  {
      throw;
  }
} 


public class ReportCredential : IReportServerCredentials
{
    public WindowsIdentity ImpersonationUser
    {
        get
        {
            return null;
        }
    }
    public ICredentials NetworkCredentials
    {
        get
        {
            return null;
        }
    }
    public bool GetFormsCredentials(out Cookie authCookie, 
                out string user, out string password, out string authority)
    {
        authCookie = null;
        user = ConfigurationManager.AppSettings["USERNAME"];
        password = ConfigurationManager.AppSettings["PASSWORD"];
        authority = ConfigurationManager.AppSettings["SERVER_NAME"];
        return true;
    }
}  
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17023021

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档