I have an ASP MVC3 application that has several HttpPost ActionResult methods. During a debug session, the methods work fine. But when I publish and view the web app in the
Never hardcode urls like this:
url: '/summary/GetAreaSelTexResult',
Always use url helpers when generating urls:
url: '@Url.Action("GetAreaSelTexResult", "summary")',
The reason your code doesn't work when you deploy it in a virtual directory is because the url /summary/GetAreaSelTexResult
is no longer correct. You must take into account the virtual directory name now: /myappname/summary/GetAreaSelTexResult
. For this reason you should never hardcode your urls but always use url helpers to generate them.
And if this is in a separate javascript file where you cannot use server side helpers you could define a global variable in your view that will point to the correct url or use HTML5 data-* helpers on some DOM element that you are working with.