I have old Asp.net web application (Visual Studio 2005) deployed in Windows Server 2012 and it runs for years. Now, we are encountering "Load report failed - Invalid Report File Path" error. Then I checked the code if the .rpt file has correct path and the actual .rpt file is already in the web server and yet, it was there. Ever since we are encountering this error, we just recycling the App pool of the application in IIS and the app runs smoothly again.
Any ideas on how this issue prevent from recurring?
Here's the snippet of my code:
reportPath = Server.MapPath("~\crm-DailyActualSalesCompressed.rpt")
pReportDoc.Load(reportPath)
pReportDoc.SetDatabaseLogon(myConInfo.UserID, myConInfo.Password, myConInfo.ServerName,
myConInfo.DatabaseName)
As the error message said you are wrong on your path, this backslash ”\” is for physical path and this slash “/” is for relative url’s which needs to mapped by Server.
So in order to read your CR file you can do that in two ways that depends on your pReportDoc
what kind of Object/type is:
If is a backend object you can do that:
reportPath = Request.PhysicalApplicationPath & "crm-DailyActualSalesCompressed.rpt"
pReportDoc.Load(reportPath)
pReportDoc.SetDatabaseLogon(myConInfo.UserID, myConInfo.Password, myConInfo.ServerName, myConInfo.DatabaseName)
If pReportDoc
is a kind of WebControl or something elese you can do that:
reportPath = Server.MapPath("~/crm-DailyActualSalesCompressed.rpt")
pReportDoc.Load(reportPath)
pReportDoc.SetDatabaseLogon(myConInfo.UserID, myConInfo.Password, myConInfo.ServerName, myConInfo.DatabaseName)
Obviously you need to know also if you CR file is on root (as seems) or included in other nested paths