[英]Call aspx web service/page from classic asp https:// site on the same server
I've got an ASP app running under SSL that I want to extend by using JQuery/Ajax and thought I'd write the methods that are called by it in .NET, hosted on the same server. 我有一个要在SSL下运行的ASP应用程序,我想通过使用JQuery / Ajax对其进行扩展,并认为我会在同一服务器上托管.NET中编写它所调用的方法。 How do I set it up?
如何设置? Should it be within the SSL domain?
它应该在SSL域内吗?
Here's an example . 这是一个例子 。 Decorate the web service with the
[ScriptService]
attribute and then invoke it: 使用
[ScriptService]
属性装饰Web服务,然后调用它:
$.ajax({
type: 'POST',
url: '/WebserviceName.asmx/MethodName',
data: JSON.stringify({
Parameter1: 'foo',
Parameter2: 'bar'
}),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(json) {
// TODO: do something with the result
}
});
You could do the same with an ASPX page with PageMethods . 您可以使用PageMethods对ASPX页面执行相同的操作 。
The only requirement is that the client is hosted on the same domain and it doesn't violate the same origin policy . 唯一的要求是客户端托管在相同的域上,并且不违反相同的原始策略 。 So for example if the .NET page is hosted on HTTPS and your client page on HTTP you cannot send AJAX requests (that's considered as a violation of the same origin policy).
因此,例如,如果.NET页托管在HTTPS上,而您的客户端页托管在HTTP上,则您无法发送AJAX请求(这被视为违反了同一原始策略)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.