Link to home
Start Free TrialLog in
Avatar of websss
websssFlag for Kenya

asked on

mvc ajax call breaks when published to virtual directory - url.action?

My MVC app works great locally, but when i publish into a virtual directory it calls the wrong path
I.e.  instead of  
Localhost/virtual/Home/PlotProbeData
it calls
Localhost/Home/PlotProbeData

Here is the piece of code in question

 
$.getJSON("/../Home/PlotProbeData", { probe: probeData }, function (data) {

Open in new window


i've looked online and it suggests using url.content or url.action, but what I tried doesn't seem to work

the above code exists inside the cshtml file.
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Is your controller called VirtualController?
Avatar of websss

ASKER

No it's called home
The virtual directory is called virtual
Guessed that much. Did you play around with ~ in URL?
Avatar of websss

ASKER

no i haven't tried that yet
Try
$.getJSON("~/../Home/PlotProbeData", { probe: probeData }, function (data) {

Open in new window

Avatar of websss

ASKER

looks like that will work when released, however when in debug mode it goes to
Localhost/Home/Home/PlotProbeData

instead of
Localhost/Home/PlotProbeData
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.