groupdocs-viewer/GroupDocs.Viewer-for-.NET

First attempt to load a document fails with Core version and Cache activated

obriankevin11 opened this issue · 14 comments

Hi,
I cloned the repo, set the license key file and launched the core demo project.

STR
When I select a file for the very first time it displays for less than a second and disappears.
If I reselect the file then it shows up correctly and doesn't disappear.
If I relaunch the program, it shows up correctly on first and subsequent openings.

Microsoft Visual Studio Professional 2022 (64-bit)
Version 17.0.4

Tested with browsers, same issue on both:
Brave is up to date Version 1.36.122 Chromium: 99.0.4844.88 (Official Build) (64-bit)
Google Chrome Version 98.0.4758.102 (Official Build) (32-bit)

I commented out the .AddLocalCache("./Cache"); and the issue doesn't happen.

@obriankevin11

I'm sorry for the delayed response. Thank you for sharing the details about the issue. Unfortunately, I've failed to reproduce it on my end. We'll continue investigating this issue and share the results with you here.

@obriankevin11

How did you launch your project?
Might you try to check with dotnet run from command-line?

Issue happens when I launch it from IDE in debug mode.

Just tried with
\Demos\ASP.NET Core\src\bin\Debug\netcoreapp3.1>dotnet GroupDocs.Viewer.AspNetCore.dll --urls=http://localhost:8080/
and it works fine.

Might you do following:

  1. Clear cache
  2. Reload the page
  3. Open the console by F12
  4. Click on settings (see pointers)
  5. Click on "Preserve log"
    image
  6. Upload the document
  7. Attach browse console here

I want to check that issue was caused by asp.net hot reload with the browser link.

Had to change the port to 9091

image

Might you scroll your console output to the top and check for "File change detected"?
Don't forget to clear cache directory and reload the page before.
image

@obriankevin11 might you paste console log here?

@obriankevin11 not requests log, but text console messages

Look at text log:
aspnetcore-browser-refresh.js:68 File change detected to css file /Cache/11sample_docx/p1.html. Reloading page...
aspnetcore-browser-refresh.js:68 File change detected to css file /Cache/11sample_docx/p2.html. Reloading page...
aspnetcore-browser-refresh.js:68 File change detected to css file /Cache/11sample_docx/p2.html. Reloading page...
aspnetcore-browser-refresh.js:68 File change detected to css file /Cache/11sample_docx/p1.html. Reloading page...

So your issue is related to AspNet core browser link auto-refresh. It is because of you running your project from Visual Studio, this feature designed specifically for Development to auto-refresh page when you update your Javascript/HTML markup, TS modules. It will not on product, only when you running your project from Visual Studio for development.

@obriankevin11

If you don't need this feature (useful for development purposes only, when you work under UI scripts/markup), you can disable this feature:

  1. Open Demos\ASP.NET Core\src\Properties\launchSettings.json
  2. Add "hotReloadEnabled": false, under "applicationUrl"

So your launchSettings.json will look as:

{
  "profiles": {
    "GroupDocs.Viewer.AspNetCore": {
      "commandName": "Project",
      "dotnetRunMessages": "true",
      "launchBrowser": true,
      "launchUrl": "viewer",
      "applicationUrl": "https://localhost:9091;http://localhost:8080",
      "hotReloadEnabled": false,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

  1. Save your file
  2. Run project in Visual Stusdio again (CTRL+F5)

ok great, problem solved.
thank you

@obriankevin11

You are welcome!