我通过 c:\
驱动器上的纯 html 文本文件发布到在我的计算机上运行的 mvc 网站:
<body>
<a id="testPost" href="./post_files/post.htm">test post</a>
<script type="text/javascript">
$("#testPost").click(function () {
$.post("http://hml.backend/Helix/Authorisation",
{
ClientIP: "192.168.20.34"
}, function (resultData) {
alert(resultData);
});
return false;
});
Controller 的设置如下:
[HttpPost]
public ActionResult Authorisation(string ClientIP)
{
string result = _videoSecurityService.CheckHelixAuthorisation(ClientIP);
return Content(result);
}
Controller 事件在调试中被命中,没有异常(exception),但 Chrome 说
'POST: Cancelled' in the debug window
有什么想法吗?
最佳答案
这是跨域调用,许多浏览器不允许这样做,因为这可能存在安全风险。您可以尝试在服务器端重定向您的调用。 (调用您自己的应用程序并处理对其他网站的请求响应)
关于asp.net-mvc - MVC 收到来自另一个网站的帖子 - Chrome 表示帖子已取消,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14647129/