Last post Feb 11, 2019 09:49 PM by PatriceSc
Feb 11, 2019 05:23 PM|peeweex10|LINK
I am working with the document viewer control. I cannot seem to set the file path to a folder on the network. (ie..\\sharename\folder\file or even its mapped drive x:\folder\file). It works just fine when I put the files in the project and run it.
Feb 11, 2019 05:41 PM|PatriceSc|LINK
Always start by telling what happens.
My guess is that you have a permission error ? The account under which your web app runs needs to have access to \\server\sharename\folder\file. If using "Application pool identity", it will be seen as DOMAIN\MACHINENAME$ when accessing a network resource: https://docs.microsoft.com/en-us/iis/manage/configuring-security/application-pool-identities#accessing-the-network
Never use a drive letter (it needs to be configured as part of the user profile) while https://en.wikipedia.org/wiki/Path_(computing)#Uniform_Naming_Convention just works
BTW not sure which "Document viewer control" you are talking about. It could be also some something related to this control (once again always tell which error message so that we don't have first to guess which error you have on your side before even suggesting
Feb 11, 2019 07:38 PM|peeweex10|LINK
I am using this control:
When I set the path to something like this:
string file = @"\\blah\blah\blah\blah.docx";
docViewer.FilePath = file;
I do not get an error...but the the control renders on the page and says "Cannot display document viewer"
However, putting the documents in the project folder and set it like this:
docViewer.FilePath = "~/Files/blah.docx";
It works just fine. In the end I want a folder on the network that we can display these files in a browser.
Feb 11, 2019 09:17 PM|PatriceSc|LINK
It uses Server.MapPath(FilePath) which is likely what fails. it would need to be updated to check if this is a virtual path or not maybe.
Also catching exceptions to show the control can't be rendered is IMO a bad idea. I would also change this so that exceptions can be handled by the caller. Finally it requires to install Microsoft Office on the server which is not recommended.
Edit: I confirm that Server.MapPath(@"\\server\name") gives c:\siteroot\server\name so :more likely it can't load the file and the control fails with its generic error message. i would drop the call to Server.MapParth and would let the consumer to provide
a physical path (possibly calling Server.MapPath himself if needed).
Feb 11, 2019 09:20 PM|peeweex10|LINK
Would you suggest another control? I would happily try something else.
Feb 11, 2019 09:49 PM|PatriceSc|LINK
Never tried yet but I noticed once that OneDrive allows to get a file using another format doing a conversion on the fly. So if acceptable if could be likely used as an entry level conversion service : https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_get_content_format?view=odsp-graph-online
You could give this a try with the biggest file you have to process and see if the UI allows to export that to PDF and see if good enough before doing that programmatically.