2013-02-01 30 views
4

我通过一个普通的HTML文本文件发布c:\驱动器上到我的MVC的网站在我的机器上运行: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; 
}); 

控制器设置如下:

[HttpPost] 
public ActionResult Authorisation(string ClientIP) 
{ 
    string result = _videoSecurityService.CheckHelixAuthorisation(ClientIP); 
    return Content(result); 
} 

控制器事件被击中在调试并没有什么异常,但Chrome的说

:在调试窗口

任何想法,为什么“POST取消”?

回答

2

这是一个跨域调用,不允许在许多浏览器中使用,因为这可能存在安全风险。您可以尝试在服务器端重定向您的呼叫。 (打电话给你自己的应用程序,并处理对其他网站的请求 - 响应)

+0

谢谢,我认为就是这样。我现在已经用一个windows窗体应用程序测试了这个帖子,代码来自:[link] http://msdn.microsoft.com/en-us/library/debx8sh9.aspx?cs-save-lang=1&cs-lang= CSHARP#代码片段 - 27 – user1444886