I think the main difference from the local and server environment is the IIS root and the virtual directory where your application is located.
I mean, if the file is in the root of the site, you can use
crystalReport.Load(Server.MapPath("/PurchaseOrder1.rpt"));
OR you can try to put the rpt file in the same folder using ViewPurchaseOrder.aspx without changing the code
If this does not work, if you can share the paths (both physical and virtual), we can additionally check.
* Edit: when using Server.MapPath
/ returns the root of the site
~/ returns the root directory of the application
The difference is that if your site:
http://yoursite.com And you have an application that is on wwwroot\somedir\app
So, in your βapplicationβ ( http://yoursite.com/somedir/app )
/ should return the root of the site ( http://yoursite.com )
~ / should return the root of the application ( http://yoursite.com/somedir/ )
source share