Cannot find external lightbox after deploying to web server

Hi,

I have a test application written in MVC 5 with razor engine. The scheduler works fine on local development PC (Windows 7). After I deployed the application to a virtual directory on my test server (i.e. abc.com/testapp), it is not able to find the external partial view I used for lightbox. I used following codes to set external lightbox in the controller:

scheduler.Lightbox.SetExternalLightbox("Home/TestForm", 500, 300);

When I checked with fiddler, it showed the path that it was trying to access is “http://www.abc.com/Home/TestForm” which is incorrect (missing the virtual application name “testapp”). How do we specify relative path in “SetExternalLightbox” method? I tried “~/Home/TestForm” but did not work. Please help! Thanks!

Hi,
try specifying url using Url.Action helper: scheduler.Lightbox.SetExternalLightbox(Url.Action("TestForm"), 500, 300);

Thanks again, Aliaksandr! I tried but still not working. Fiddler showed the host name now has controller name. Please help.

In case someone has the same issue, I solved this by using a web.config key (may not be the best solution but it works for me).

<add key="VirtualApplicationName" value="TestApp" />

Set it to to nothing when in development environment. In the controller’s action method, do:

            string virtualAppName = ConfigurationManager.AppSettings["VirtualApplicationName"];
            string lightboxUrl = string.Empty;
            if (string.IsNullOrEmpty(virtualAppName))
                lightboxUrl = "Home/TestForm";
            else
                lightboxUrl = string.Format("{0}/Home/TestForm", virtualAppName);
            scheduler.Lightbox.SetExternalLightbox(lightboxUrl, 500, 300);