Lucas
Lucas

Reputation: 534

ReportViewer working locally, not working in server

<rsweb:ReportViewer ID="ReportViewer1" runat="server" SizeToReportContent="True">
    <LocalReport ReportPath="/Activity/Reports/Report.rdlc">
        <DataSources>
            <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="dsActivity" />
            <rsweb:ReportDataSource DataSourceId="ObjectDataSource2" Name="dsPoints" />
            <rsweb:ReportDataSource DataSourceId="ObjectDataSource3" Name="dsEnterprise" />
        </DataSources>
    </LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="ListAct" TypeName="App.BL.Activity"></asp:ObjectDataSource>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="ListPts" TypeName="App.BL.Points"></asp:ObjectDataSource>
<asp:ObjectDataSource ID="ObjectDataSource3" runat="server" SelectMethod="ListEtp" TypeName="App.BL.Enterprise"></asp:ObjectDataSource>

This code works when debugging, but when I publish it on the server, it gives the following error message:

An error occurred during local report processing.
The report definition for report 'Report' has not been specified
Could not find file 'E:\Groups\Tech\appWebHlg\Report.rdlc'.

Somehow the ReportPath is not getting it to the Report.rdlc, how can I find it on server-side? Is there any absolute path I can use? How can I make the ReportViewer find the Report?

Upvotes: 0

Views: 1213

Answers (1)

tgolisch
tgolisch

Reputation: 6734

You need to change your ReportPath for your server. The ReportPath needs to be an absolute path on the HDD of your server.

Most people find that it is best to set the report path in code, when executing the report. For example (c#)

if (ReportViewer1.LocalReport.ReportPath.BeginsWith("/")) {
    string realpath = Server.MapPath(ReportViewer1.LocalReport.ReportPath);
    ReportViewer1.LocalReport.ReportPath = realpath;
}
ReportViewer1.LocalReport.Refresh();

Upvotes: 1

Related Questions