What version of MVC are you using.
In MVC 3.0, with Razor, you can use:
@Url.Action("SqlQuery","SqlReportList")
or you can use:
@Server.MapPath("~")
to get the base address of your application, and then create it yourself. Server.MapPath also works in the controller if that helps. (It seems that the Url class is also available in the controller)
(from memory)
edit comment:
If you are in the .cshtml file, it will look like this:
function ddlSqlList_onchange(listItemId) { $.get('@Url.Action("SqlQuery","SqlReportList")', { "listItemId": listItemId }, function (data) { alert('succeeded'); $('#tbSqlQuery').text(data); });}
source share