从 javascript 调用 webform 身份验证页面后面的 .net web 服务

Calling .net web service behind webform authentication page from javascript

我正在尝试调用位于需要 Web 表单身份验证的 Web 服务器上的 Web 服务

 $.ajax({
                    type: "Get",
                    url: "http://SomeIPAddressThatIDontWantToShare/WebServices/GetServerData.asmx/GetOPCHist_Last4h",
                    data: { OPCName: OPCName_Passed, OPCTable: OPCTable_Passed },
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                        $.each(data, function (index, element) {
                            T1.push([new Date(element.DateAndTime).getTime(), element.T1]);
                        });
                    },
                    error: function (request, status, error) {
                        alert(request.status + ' ' + request.responseText);
                    }
                })

然而,当这样做时,它总是会遇到状态为“0”的错误状态,并且响应文本没有任何内容。在点击页面之前,我在浏览器上手动进行了身份验证。

所以问题是,我是否必须从 javascript 进行 Web 表单身份验证,如果是,如何进行?

此错误是否与 Web 表单身份验证有关,或者状态 0 可能完全不同。

我验证了从浏览器登录后我可以访问该网络服务。

如果您的服务受网络表单保护,您当然必须先登录。 检查 this 以尝试为您的 ws 删除 webforms 保护。 或者您可以尝试 this one 在网络表单中工作。

希望对您有所帮助