Closed aramka closed 7 years ago
Hi @aramka, Thanks for your input and interest in WDV in general. I've run through your sample. Long story short, it's happened because of the issue in our code which appeared itself because jquery is included to the page twice in this particular sample.
First time jquery is included directly in DocViewerInTypicalMvcDirectoryStructure, right before WDV script. We are capturing jQuery gloabal variable to our local varable("$" as a standart practice) to avoid global scope naming conflicts.
Then Jquery is included second time from _Layout.cshtml(@Scripts.Render("~/bundles/jquery")) and the global jQuery variable gets overridden with the new instance. After that moment all our internal checks of "instanceof jQuery" are broken and it leads to the incorrect pages load.
Workaround would be to include Jquery only once. But the drawback is that since WDV requires jquery to be already defined on the page, it will be uncomfortable to include WDV to the particular page and still have scripts incusion on the bottom of html page.
Hope that helps,
I have removed the _Layout.cshtml from the project completely and I have removed all jquery bundles. Now, jquery is loaded only once in the head of the page.
But the behavior is the same. The image never loads. I checked in the changes if you can look.
Hi @aramka, new version is working for me, except path to the document is not correct - 'documenturl: '../../Invoice.pdf'' causes error on loading document metadata - path goes out of app virtual directory.
I've modified it to the 'documenturl: '~/Invoice.pdf'' and it works for me. Also i'd suggest to subscribe to document lifecycle events to make process more visible.
I've created a pull request demonstrating the changes - https://github.com/aramka/AtalasoftWebDocumentViewer/pull/1 hope that will help this time.
If you have a specific use case or want to discuss other WDV features feel free to contact us here or our support - usually they are very friendly. p.s. we are trying to rollout API reference for javascript side. It's targeted for upcoming release, but most features are presented in 10.7 so you could take a look in it if you'll be interested - https://atalasoft.github.io/web-document-viewer
Yes, this issue looks like its fixed. I have merged your changes.
Thank You.
Im trying to get the web document viewer to work in an mvc razor view. Is this scenario supported?
I have an Index.cshtml file inside a directory structure like
root-->views-->DocViewerInTypicalMvcDirectoryStructure
The out of the box VS asp.net mvc project template creates the directories like this.
My Index.cshtml looks like
The page gets served up and I see the handler(ashx) is hit. It looks like the viewer gets initialized, it turns the div into a viewer with thumbs, but the image never gets loaded. Also, there are no errors, 404, 500, etc, in the dev tools network tab.
Also, if I put the same code above into a regular html file in the root of the project, or a sub directory, and adjust the relative paths accordingly then I can get it to work. But I cannot get the Index.cshtml to work.
I've cloned your demo and it does not use razor views, cshtml. Nor does it use the typical asp.net mvc scaffolded directory structure. It uses an html file in the root.
Will the document viewer work in cshtml files, razor views, in the typical ( typical-scaffolded VS ASP.NET MVC project template) folder structure?
I have a github repo here
git@github.com:aramka/AtalasoftWebDocumentViewer.git
That illustrates the issue.
Any insight or direction is greatly appreciated.
Thank You.