Viewer resources handlers url problem

Hi, i’m using Viewer 2.16 in mvc project and there’s a problem with resources url generation. With IIS Express it works well, but with Local IIS, when opening a document, there’s a lot of 404 errors. The problem is due to the fact that the resource url is http://localhost//Get, instead of http://localhost//document-viewer/Get…

This bug was opened by us some months ago and seems to be a regression.
Version 2.15.1 seems to work fine but there are problems with other bugs we opened earlier…
Please help me quickly with this issue,
Gianluca

Hi Gianluca,


Please try to set base url in the Viewer initialization just after Viewer.SetRootStoragePath()
For example:

Groupdocs.Web.UI.Viewer.SetBaseUrl(“http://localhost/”);

Best regards.

Hi Pavel, the problem is that on Global.asax i don’t have access to Context.Request to calcolate the url…


Gianluca

Hi again,


In such case you have two variants:
1. Set the base URL as I suggested not in the Global.asax but in the any other place where you will already have access to the Context.Request but before the first call to the Viewer. For example in the first line of the Page_Load action for the Viewer web page
2. Use Viewer 2.17 - in the latest version this issue is fixed

Best regards.

I tried the first option but doesn’t seems to work. Can be depend on the .UseHttpHandlers(false) setted on script block generation ?

Hi,


First of all if your application is web forms app you must set this option to true: .UseHttpHandlers(false) and don’t forget to add handlers to the web.config. In case that your app is MVC - yes you should set it to false.

Also please share with me the screenshot or code example for this change.

Thank you.
Yes, i'm running it on an MVC project. Here there is my code, i can't find a critical point....
Gianluca


Hi,

And what the value you have in the "url" variable when you set the base URL?

Thank you

Its the string value builded in the previous line, sorry for the bad indentation!

Hi,


Thank you for the clarification but I need to know the exact value of the variable.

Thank you.

Oh sorry for the misunderstanding, it’s http://localhost/test.Url/

Hi again,


Here is a solution which works perfectly on my local:

protected void Application_BeginRequest(Object source, EventArgs e)
{
Groupdocs.Web.UI.Viewer.SetBaseUrl(System.Web.HttpRuntime.AppDomainAppVirtualPath);
}

This code should be added in the Globals just after “Application_Start”

Best regards.

Thanks for the snipped, i tried it and works well!

But won’t this slow down all the request process management?

Hi,


No, it shouldn’t.

Best regards.