Search code examples
.netvisual-studio-2013reportviewervisual-studio-lightswitch

MS Lightswitch 2013 - Windows Authentication causes Errors in MS Reportviewer


I am using VS Lightswitch 2013 for our site. I implemented reporting using the MS ReportViewer and created several reports some of which have fields using a raw field from the dataset and other fields I am using expressions to generate the desired field value. These have been working for several months now with no issues.

Recently, I added Windows authentication into the site. I made no changes to my reporting functionality during this implementation. Now the fields that were generated using expressions do not work. The show as "#Error" when the report is rendered. The rest of the report generates with no issues.

Here are a few test examples that I ran:

="Hello" & " World" renders "Hello World"

=Fields!FirstName.Value renders "John"

="Hello" & Fields!FirstName.Value renders"#Error".

=Fields!FirstName.Value & Fields!LastName.Value renders "#Error".

When I disable authentication this expression returns the correct value. Enabling authentication renders these respective values = "#Error".

I checked the changeset from the release prior to implementing the windows authentication and the Reports work correctly. The next release was the windows authentication release and this is where the reports started breaking. Like I said there were no other changes to the reporting side of things during the release.

Can anyone provide some insight into why authentication would break the reports?

Please help me Obi Wan. You're my only hope!


Solution

  • In the Page_Load event handler of your webpage that is hosting your Reportviewer try this:

    protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                // ...your code that fetches the data and initializes your ReportViewer Control...
    
    
                this.ReportViewer1.LocalReport.SetBasePermissionsForSandboxAppDomain(AppDomain.CurrentDomain.PermissionSet.Copy());
    
    
    
    
            }
        }