Free Support Forum - groupdocs.com

Previewer Could not find a part of the path Error

Hi,

we are using version 2.19 of the product. intermittently we are getting the following error when previewing documents. Any ideas on what the cause could be? Everything is setup correctly.

Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 29/09/2017 13:43:40
Event time (UTC): 29/09/2017 12:43:40
Event ID: 7010b0459a1c494ab736ac3bddc512a4
Event sequence: 5171
Event occurrence: 81
Event detail code: 0

Application information:
Application domain: ******
Trust level: Full
Application Virtual Path: /
Application Path: D:\PlatformPortal\SharePoint Document Viewer\
Machine name: ******

Process information:
Process ID: 4164
Process name: w3wp.exe
Account name: IIS APPPOOL\SPPREVIEW

Exception information:
Exception type: DirectoryNotFoundException
Exception message: Could not find a part of the path ‘c:\windows\system32\inetsrv\temp\Cache\temp\S\17d6f209-74d8-489d-a6b2-c442021c406d.docx’.
at Groupdocs.Web.UI.Handlers.BaseAspNetHandler.OnException(Exception exception, HttpContext context)
at Groupdocs.Web.UI.Handlers.BaseAspNetHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Request information:
Request URL: *****/document-viewer/GetDocumentPageImageHandler?path=temp\S\17d6f209-74d8-489d-a6b2-c442021c406d.docx&width=639&quality=75&usePdf=False&useHtmlBasedEngine=False&rotate=False&locale=en-US&pageIndex=0
Request path: /document-viewer/GetDocumentPageImageHandler
User host address: 172.17.0.188
User:
Is authenticated: False
Authentication Type:
Thread account name: IIS APPPOOL\SPPREVIEW

Thread information:
Thread ID: 12
Thread account name: IIS APPPOOL\SPPREVIEW
Is impersonating: False
Stack trace: at Groupdocs.Web.UI.Handlers.BaseAspNetHandler.OnException(Exception exception, HttpContext context)
at Groupdocs.Web.UI.Handlers.BaseAspNetHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Custom event details:

Hi @danielmcgrath We are sorry to hear that you have such issue. According to the stack trace of the error the Viewer can’t find the file http://prntscr.com/gr6ujo . Could you please check if such file and path exists. Also make sure that you have free space on the C:\ drive to save temp data of the Viewer.

If this will not help - please check our documentation here especially the RemoveOldEntries method and clear the temp data via it. This will force the Viewer to regenerate temp data for the viewed file.

Best regards.

Hi,

Many thanks for getting back to me.

We have specified the following property as a completely different folder, i.e. D:\PlatformPortal\SharePoint Document Viewer\Temp - which does exist

Groupdocs.Web.UI.Viewer.SetRootStoragePath(RootStoragePath);

The drive has plenty of available disc space.

For some unknown reason it seems previewer wants to use a different path for the storage location. All the code seems sound. We just can’t explain it.

Any ideas?

Regards,
Dan.

Hi @danielmcgrath in such case could you please share the all Viewer related code that I can check it on my side.

Best regards.

Currently. We have a asmx service. We pass into it various parameters. I have checked our settings and used Fiddler to track these and are 100% certain we are passing in the correct and expected values.

DocURL = DocURL.Replace(""", string.Empty);
RootStoragePath = RootStoragePath.Replace(""", string.Empty);
LicensePath = LicensePath.Replace(""", string.Empty);
Height = Height.Replace(""", string.Empty);
Width = Width.Replace(""", string.Empty);
OrgName = OrgName.Replace(""", string.Empty);

        Groupdocs.Web.UI.Viewer.SetRootStoragePath(RootStoragePath);
        Groupdocs.Web.UI.Viewer.SetLicensePath(LicensePath);

        //Create a stream for the file
        System.IO.Stream stream = null;
        System.Net.HttpWebResponse fileResp = null;
        System.Net.HttpWebRequest fileReq = null;
        NetworkCredential nc = null;
        CredentialCache cache = null;

        var username = ConfigurationManager.AppSettings["SharePointUserName"].ToString();
        var password = ConfigurationManager.AppSettings["SharePointPassword"].ToString();
        var domain = ConfigurationManager.AppSettings["SharePointDomain"].ToString();

        var configUsername = ConfigurationManager.AppSettings["SharePointUserName"].ToString();
        var configPassword = ConfigurationManager.AppSettings["SharePointPassword"].ToString();
        var configDomain = ConfigurationManager.AppSettings["SharePointDomain"].ToString();

        //Get Credentials from App Settings
        if (!string.IsNullOrEmpty(OrgName))
        {
            PeppermintNotificationService.SharepointNotificationServiceClient snc = new PeppermintNotificationService.SharepointNotificationServiceClient();
            var spCredentials = snc.GetSharePointCredentials(new LogonInfo() { AccessKey = new Guid("{E4E01277-D41E-4F0E-9699-8F9E1619AD27}"), Organization = OrgName });

            if (spCredentials.Success)
            {
                var res = spCredentials.Result;

                if (!string.IsNullOrEmpty(res.Username) && !string.IsNullOrEmpty(res.Password) && !string.IsNullOrEmpty(res.Domain))
                {
                    username = res.Username;
                    password = res.Password;
                    domain = res.Domain;
                }
            }
        }

        //Set Credentials
        nc = new NetworkCredential(username, password, domain);
        cache = new CredentialCache();
        cache.Add(new Uri(DocURL), "NTLM", nc);
        
        //Create a WebRequest to get the file
        fileReq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(DocURL);
        fileReq.Credentials = cache;

        try
        {
            //Create a response for this request
            fileResp = (System.Net.HttpWebResponse)fileReq.GetResponse();
        }
        catch
        {
            //Try the credentials from the web.config file

            nc = new NetworkCredential(configUsername, configPassword, configDomain);
            cache = new CredentialCache();
            cache.Add(new Uri(DocURL), "NTLM", nc);

            //Create a WebRequest to get the file
            fileReq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(DocURL);
            fileReq.Credentials = cache;

            //Create a response for this request
            fileResp = (System.Net.HttpWebResponse)fileReq.GetResponse();
        }

        //Get the Stream returned from the response
        stream = fileResp.GetResponseStream();
        var fileName = Guid.NewGuid().ToString();

        return Groupdocs.Web.UI.Viewer.ClientCode()
         .TargetElementSelector("#test")
         .Stream(stream, fileName, GetFileExtension(DocURL), GetFileName(DocURL, false))
         .EnableRightClickMenu(false)
         .ShowThumbnails(true)
         .OpenThumbnails(false)
         .ShowFolderBrowser(false)
         .Height(Convert.ToInt32(Height))
         .Width(Convert.ToInt32(Width))
         .SupportTextSelection(false)
         .Quality(75)
         .Zoom(75)
         .ShowSearch(false)
         .Layout(ViewerMode.OnePageInRow)
         .PreloadPagesCount(1)
         .ShowViewerStyleControl(false)
         .UseHtmlBasedEngine(false)
         .ToString();

Hi @danielmcgrath thank you for the source code. I will investigate it and then return to you.

Best regards.

Hi @danielmcgrath I have checked your code and looks like all should work fine, at least it does on my side. I have tried to view the pdf document located in the Web via your code (just removed the credentials functionality) as you can see on the screenshot.
I also wanted to clarify the next:

  1. Do you use different root storage paths or the root storage path is never change. If it always the same then please move this code
    Groupdocs.Web.UI.Viewer.SetRootStoragePath(RootStoragePath);
    Groupdocs.Web.UI.Viewer.SetLicensePath(LicensePath);
    to the section where it will be called only once per application start.
  2. Please make sure that after changing root storage path to “D:\PlatformPortal\SharePoint Document Viewer\Temp” you have cleared the application pool to ensure that it uses the new path and not the cached one.
  3. Does this functionality worked well previously and you started to receive this error just now or not?

Also I should notify you that you use a very old version of the Viewer library which is not supported any more and I want to offer you to take a look at our latest Viewer plugin for SharePoint.

Best regards.

Hi - thank you for getting back to me.

Point 1 - We specify the paths in a property bag in SharePoint and pass them into the viewer. One set they don’t change but they will be different for our various customers.

Point 2 - We have tried this already as well as doing IISResets

Point 3 - At the moment the issue is related to one customer in particular. Other installs have not exhibited the behaviour and are working as expected. We do suspect there a setup issue somewhere but can’t find any discrepencies.

Regards

Hi @danielmcgrath thank you for this information. In this case I can suggest you next: Set the root storage path identical for all - this removes the need to re-set it every time for each user. Also since you use a direct file URL to view the document you don’t need to set root storage path for each user - the file isn’t stored locally, only it’s cache, so there is no sense to use different paths for root storage. Using different paths have since only if you need to store the documents in different storage for each user - cloud, locally or somewhere else.

Best regards.

Thank you for your assistance - we manage to resolve the issue in the end. We changed the path to a different drive and that has seems to have done the trick.

I do have a further follow up question. I can open a new thread if needed.

We have the following code below.

We are finding however that that since using useCachedStreamIfPossible = true it is only showing the cached version even though the file in SharePoint has changed. How do we reset/clear the cache? We have tried clearing the temp files folder but the cache still remains. If we do need to change this property back false - are there any other properties we can change to improve performance?

stream = fileResp.GetResponseStream();
var fileName = DocURL.GetHashCode();

        return Groupdocs.Web.UI.Viewer.ClientCode()
         .TargetElementSelector("#test")
         .Stream(stream, fileName.ToString(), GetFileExtension(DocURL), GetFileName(DocURL, false), true)
         .EnableRightClickMenu(false)
         .ShowThumbnails(true)
         .OpenThumbnails(false)
         .ShowFolderBrowser(false)
         .Height(Convert.ToInt32(Height))
         .Width(Convert.ToInt32(Width))
         .SupportTextSelection(false)
         .Quality(75)
         .Zoom(75)
         .ShowSearch(false)
         .ShowOnePageInRow(true)
         //.Layout(ViewerMode.OnePageInRow)
         .PreloadPagesCount(1)
         .ShowViewerStyleControl(false)
         .UseHtmlBasedEngine(false)
         .ToString();

Hi @danielmcgrath Glad to hear that you have resolved the issue.

By default, when you open a web-page with GroupDocs.Viewer widget, and the target document is invoked (for displaying), on the server-side GroupDocs.Viewer converts the document to the images and text (for the image-based rendering) or to the HTML, images, fonts, and CSS (for the HTML-based rendering). Only when this conversion process is finished, GroupDocs.Viewer begins to transmit data to the client-side and end-user can see content of the document in the browser. That’s why it takes so much time - GroupDocs.Viewer needs to convert all document, and they are really big. The conversion speed depends on the performance of the server - CPU, memory, storage.

Here is some methods that can improve the performance:

  1. Try to use HTML-based rendering mode (“UseHtmlBasedEngine(true)” method) if it is suitable for you and there are no document distortions.
  2. Use “MinimumImageWidth(value)” method. MinimumImageWidth: if set, the Viewer will load page images with the specified width from the server when starting. It will not load page images from the server again after zooming if the current page image size is smaller than the value specified and if the original (not scaled) page image size is smaller than the value specified. It means that in most cases the GroupDocs.Viewer will load page images only once and will not reload them after zooming in/out.
  3. If this is possible for your business-logic, disable thumbnails (“ShowThumbnails(false)”).
  4. If this is possible for your business-logic, disable ability to select text by using “SupportTextSelection(false)” method.
  5. Use “ShowViewerStyleControl(false)” method - it will disable “double page flip” option and will increase performance.

As for the cache question - you can use public void RemoveOldEntries(TimeSpan olderThan, string logFilePath = null) method of the DocumentCache class to remove old cache. Also please investigate this documentation for more information about cache functionality.

Best regards.

Hi,

Many thanks for reply. I have implemented those recommendations and can see some improvement. However… as part of the service I added the following code:

Groupdocs.Web.UI.DocumentCache dc = new DocumentCache(LicensePath, RootStoragePath);
dc.RemoveOldEntries(new TimeSpan(0, 0, 10, 0));

After 10 minutes however I started getting document not found errors. Is there something I am missing that needs adding?

Hi @danielmcgrath Glad to hear that you have improved the performance.
As for the error - please try to add path for the log file into the dc.RemoveOldEntries(new TimeSpan(0, 0, 10, 0), @“c:\GDViewerTmp\cache_clean_log.txt”); or some other path to found out cache cleaning details.

Best regards.

Hi,

I added the path and are now getting log details.

What happen is I upload a new file and preview it. This works. After 10 minutes I start getting ‘Document not found’ errors. Upon each request the log file inserts the following.

Local time:10/25/2017 09:23:19, UTC time:10/25/2017 08:23:19 *** RemoveOldEntries started. The Timespan is 00:10:00
Local time:10/25/2017 09:23:19, UTC time:10/25/2017 08:23:19 RemoveOldEntries for the processing folder started.
Local time:10/25/2017 09:23:19, UTC time:10/25/2017 08:23:19 RemoveOldEntries for the processing folder completed
Local time:10/25/2017 09:23:19, UTC time:10/25/2017 08:23:19 RemoveOldEntries for the cache folder started
Local time:10/25/2017 09:23:19, UTC time:10/25/2017 08:23:19 RemoveOldEntries for the cache folder completed
Local time:10/25/2017 09:23:19, UTC time:10/25/2017 08:23:19 RemoveOldEntries for the stream folder started
Local time:10/25/2017 09:23:19, UTC time:10/25/2017 08:23:19 Found:C:\SharePointDocumentPreviewer\TempFiles\temp\S\2003529892.docx, UTC time:25/10/2017 08:05:51
Local time:10/25/2017 09:23:19, UTC time:10/25/2017 08:23:19 Removing:C:\SharePointDocumentPreviewer\TempFiles\temp\S\2003529892.docx
Local time:10/25/2017 09:23:19, UTC time:10/25/2017 08:23:19 RemoveOldEntries for the stream folder completed

Hi @danielmcgrath Please try to set useCachedStreamIfPossible back to false. Looks like the following happens: RemoveOldEntries removed all cached files and when you tries to view the document again Viewer can’t find any cached files and do not generates it again since useCachedStreamIfPossible is true.

Best regards.

Hi,

Many thanks for your reponse. Am I right in assuming that is a bug in the version we are using and can’t take advantage of the useCachedStreamIfPossible property?

Hi @danielmcgrath . yes you are right its a bug in the version you are using.
Also I should notify you that this version of the library is a very old and not supported any more - this means that the bugs in it will not be resolved. If you need to resolve the bugs you should migrate to the latest version of the library. If you need help with migrating please create a new forum thread.

Best regards.

Thanks for confirming and many thanks for help and assitance.

Hi @danielmcgrath You are welcome.

Best regards.