Ajax通过https SSL调用

时间:2015-01-14 21:05:57

标签: c# ajax https

我有一个jquery Ajax调用试图调用webmethod。它适用于所有环境,但不能一次部署到生产环境。唯一的区别是生产使用HTTPS SSL。

这是我的ajax代码

$.ajax({
        type: "POST",
        url: "https://www.mywebsite.ca/assure/demandeconfirmee.aspx/EnvoyerAuxAssureurs",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: 'text',
        success: function (msg) {
        console.log(msg);
        },
    error: function (xhr, ajaxOptions, thrownError) {
        console.log(xhr.status);
        console.log(thrownError);
        }   
    });

和我的webmethod

[WebMethod]
public static string EnvoyerAuxAssureurs()
{
    return "YanTest";
}

在https上执行ajax应该是直截了当的吗?!

在我测试的每个环境中,我都会回复“yanTest”。

但是,在https(生产)下,我得到以下答案(在评论中使用http而不是https返回称为url):

 <html><head><title></title><!-- <script language="javascript">window.location.replace("http://www.mywebsite.ca/assure/demandeconfirmee.aspx/EnvoyerAuxAssureurs");</script> --></head><body></body></html>

任何输入?

!!!问题解决了!!!! 重定向是由导致重定向的我的WebPageSecurity.dll模块引起的,我已将以下内容添加到我的web.config中,它现在可以正常工作了!

<secureWebPages mode="On" maintainPath="True" warningBypassMode="AlwaysBypass" bypassQueryParamName="BypassSecurityWarning" ignoreHandlers="WithStandardExtensions">
<files>
    <add path="Assure/DemandeConfirmee.aspx/EnvoyerAuxAssureurs" secure="Ignore" />
</files>

1 个答案:

答案 0 :(得分:0)

!!!问题解决了!!!!重定向是由导致重定向的我的WebPageSecurity.dll模块引起的,我已将以下内容添加到我的web.config中,它现在可以正常工作了!

    <secureWebPages mode="On" maintainPath="True" warningBypassMode="AlwaysBypass" bypassQueryParamName="BypassSecurityWarning" ignoreHandlers="WithStandardExtensions">
<files>
    <add path="Assure/DemandeConfirmee.aspx/EnvoyerAuxAssureurs" secure="Ignore" />
</files>