Since you are using MVC, you can search for Url.Action :
@Url.Action("GetMsg","Home")
Also, if you intend to use paths in Javascript, it might be a good idea to use hidden elements with this path so that you can use Javascript from the outside, for example:
@Html.Hidden("GetMsgPath",Url.Action("GetMsg","Home")) $.ajax({ type: "GET", url: $("#GetMsgPath").val(), success: function (result) { }, error: function (req, status, error) {} });
source share