I have a jquery Ajax call trying to call a webmethod. It works for all environment but not once deployed to production. The only difference is production use HTTPS SSL.
Here is my ajax code
$.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);
}
});
and my webmethod
[WebMethod]
public static string EnvoyerAuxAssureurs()
{
return "YanTest";
}
Doing ajax over https should be straight forward no?!
on every environment i test it I recieve "yanTest" in response.
However, under https (production) I get the following answer (called url is returned in comment..with http instead of https) :
<html><head><title></title><!-- <script language="javascript">window.location.replace("http://www.mywebsite.ca/assure/demandeconfirmee.aspx/EnvoyerAuxAssureurs");</script> --></head><body></body></html>
Any input?
!!!Problem Solved!!!! Redirect was caused by my WebPageSecurity.dll module that was causing a redirection, I've added the following to my web.config and it now works!
<secureWebPages mode="On" maintainPath="True" warningBypassMode="AlwaysBypass" bypassQueryParamName="BypassSecurityWarning" ignoreHandlers="WithStandardExtensions">
<files>
<add path="Assure/DemandeConfirmee.aspx/EnvoyerAuxAssureurs" secure="Ignore" />
</files>