locked
Unable to load a Devexpress Report after deploying project in Windows Server 2019 with IIS 10 RRS feed

  • Question

  • User-1281910254 posted

    My first post in this forums.

    TITLE SHOULD BE: "Unable to load a Devexpress Report for the currentUser..."

    I'm developing a little MVC 5, EF, code first website based on the sample project AspnetIdentitySample with user's identity/membership.
    Everything so far is great. Now I'm adding a report feature using a trial version of Devexpress Xtrareport.
    I am able to design a report layout and save it in a root folder called Reports with the extension .resx.

    I am able to have the logged in users to produce their own pdf using the report layout as well as a customized layout where they can add their own logo etc.
    I choose to let the users save their own reports layout using this code at the controller:

           //WILL CREATE THE DIRECTORY IF DOESN'T EXISTS
            [HttpPost]
            public ActionResult ReportDesignerSaveLayout(string ReportDesigner)
            {
                using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(ReportDesigner)))
                {
                    Session["ReportStorage"] = ms.ToArray();
                }
                if (!System.IO.Directory.Exists(@"c:\Reports"))
                {
                    System.IO.Directory.CreateDirectory(@"c:\Reports");
                }
                return Json(new { success = true });
            }
    
           ////WILL OPEN THE POPUP OPEN/SAVE WINDOWS
            public ActionResult ReportDesigner_ExportLayout()
            {
                byte[] reportLayout = (byte[])Session["ReportStorage"];
                if (reportLayout != null)
                {
                    Session["ReportStorage"] = null;
                    return File(reportLayout, "application/repx", "MyReport.repx");
                }
                else
                {
                    return View("Index");
                }
            }
    
    //And they can load their reports using this code:
            public ActionResult WebDocumentViewer(int? WOId)
            {
    
                var report = new AspnetIdentitySample.Reports.MyReport();
                var filePath = @"C:\Reports\MyReport.repx";
                    if (System.IO.File.Exists(filePath))
                    {
                    using (var stream = new MemoryStream(System.IO.File.ReadAllBytes(filePath)))
                        report.LoadLayout(stream);
                        report.Parameters["pWorkOrder"].Value = WOId;
                        report.RequestParameters = false;
                        return View(report);
                    }
                 return View(report);
            }

    Everything works fine in my developing machine but when I publish it in my server it keeps on searching C:\ directory inside the Windows Server instead of the users machine and then give the error message: "Could not find file 'C:\Reports\MyReport.repx'."

    If I add the file MyReport.repx there in the server's C:\ drive it works but the main idea is to have the users loading their document using their own layout saved in their own hard drive.

    I'm using the file method to publish the website using this path: C:\bin\Release\Publish, then I copy and paste the whole thing into the IIS.
    How can I make this thing to search the file in the users machine instead of the server?

    Any help will be appreciated

    Monday, July 27, 2020 4:07 AM

Answers

  • User475983607 posted

    Just curious about this answer: "Simply, your design will not work..."

    Any other design will do the trick?

    Sorry about my insistence

    I explained why above.  The file must be located on the web server where the code is running.   It seems to work during development because the development machine is both the web server and the client.  Once deployed the distinction is made clear.  This is a common oversight with new website developers. 

    You'll need to come up with a design that stores the report file in the web server.   I recommend contacting DevExpress for assistance with the 3rd party tool.  They should be able to give you source code or point you to examples.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, September 27, 2020 7:06 PM

All replies

  • User-474980206 posted

    The code that runs on the server can only write to servers drive. When you run on the local machine, the server drive just happens to also be the client drive.

    Monday, July 27, 2020 2:29 PM
  • User-1281910254 posted

    bruce (sqlwork.com)

    The code that runs on the server can only write to servers drive. When you run on the local machine, the server drive just happens to also be the client drive.

    Thanks Bruce for your response.

    I tried with my son's laptop, same thing. I can download MyReport.repx file to his hard drive, but can not read back.

    Depending on the users browser settings this code let them download the .repx layouts but it will not read. I added a view to redirect the user to the designer page where he can modify and save the file

    I tried this but nothing. It will prompt to save it even if the file exists

           public ActionResult WebDocumentViewer(string WOId)
            {
                var report = new MyReport();
    
                //MyReport report = new MyReport();
                string reportFilePath = @"C:\Reports\MyReport.repx";
    
                if (System.IO.File.Exists(reportFilePath))
                {
                    report.LoadLayout(reportFilePath); //empty report
                    report.Parameters["pWorkOrder"].Value = WOId;
                    report.RequestParameters = false;
                }
                else
                {
                    return View(ViewBag.Message = "MsgFailedInvokeSaveFile");
                }
                return View(report);
            }

    Monday, July 27, 2020 9:39 PM
  • User475983607 posted

    Simply, your design will not work.  The file must be on the server as that's where the code is running.  The server sends the results to the browser and browser just displays the report.  the browser has not concept of an repx file.

    Monday, July 27, 2020 9:55 PM
  • User-1281910254 posted

    Simply, your design will not work.  The file must be on the server as that's where the code is running.  The server sends the results to the browser and browser just displays the report.  the browser has not concept of an repx file.

    Thanks mgebhard. They claim it will work. Will try couple of other options (like saving it in the database with identity) and then will move on with a different Ad Hoc Reporting Tool. A have read a lot of complaints from customers.

    Thanks

    Monday, July 27, 2020 10:32 PM
  • User-1281910254 posted

    Just curious about this answer: "Simply, your design will not work..."

    Any other design will do the trick?

    Sorry about my insistence

    Sunday, September 27, 2020 5:59 PM
  • User475983607 posted

    Just curious about this answer: "Simply, your design will not work..."

    Any other design will do the trick?

    Sorry about my insistence

    I explained why above.  The file must be located on the web server where the code is running.   It seems to work during development because the development machine is both the web server and the client.  Once deployed the distinction is made clear.  This is a common oversight with new website developers. 

    You'll need to come up with a design that stores the report file in the web server.   I recommend contacting DevExpress for assistance with the 3rd party tool.  They should be able to give you source code or point you to examples.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, September 27, 2020 7:06 PM
  • User-1281910254 posted

    Thank you

    Monday, September 28, 2020 10:58 AM