ASP MVC3 - HttpPost action not found after publish

浪子不回头ぞ 提交于 2019-12-01 01:09:33

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!