0

Below code is in my website:

 function validateRequest() {
    var $form = $('form');
    if ($form.valid()) {

        $.support.cors = true;

        var lnkey = $('#txtloan').val();
        var psw = $('#txtpsw').val();
        var loanServiceUrl = @Html.Raw(Json.Encode(ConfigurationManager.AppSettings["LoanServiceURL"]));
        var msg = {"loan": lnkey, "psw": psw};

        $.ajax({
            cache: false, 
            async: true,
            type: "POST",
            url: loanServiceUrl + "ValidateRequest",                
            data: JSON.stringify(msg),
            contentType: "application/json; charset=utf-8",
            dataType: "json",  //jsonp?                
            success: function (response) {
                $(response).each(function(i, item) {

                    if (item.Validated.toString().toUpperCase() == 'TRUE') {
                        // When validation passed
                        $('#divResult').load('@Url.Action("GetLoanInfo", "Validate")');
                        $("#btnClearStatus").show();
                        $('#btnGetStatus').hide();
                    }                        
                });                 
            },
            error: function (errormsg) {
                alert("ERROR! \n" + JSON.stringify(errormsg));                   
            }
        });            
    } 
}      

I have set following setting in IIS where my service is deployed.

enter image description here

When I make a POST call from website, I see two calls (probably one is pre-flight call for CORS) in fiddler. This is working fine in chrome and Safari but not in Firefox. I get HTTP 405 error. I am using Firefox 21.0.

Below is the snap shot from fiddler when service is called from firefox.

enter image description here

sharp_net
  • 737
  • 2
  • 5
  • 12
  • Seems like it is an OPTIONS call, which might not be authorized through WCF, which fails. Why do you need the OPTIONS method in your access-control-allow-methods in your IIS config ? This might be useful http://stackoverflow.com/q/4875195/1236044 – jbl Jun 26 '13 at 15:21
  • jbl, I removed OPTIONS from access-control-allow-methods in IIS. But no luck yet. – sharp_net Jun 26 '13 at 23:31
  • I'm afraid you in fact need this OPTIONS in your IIS config. What you have to do seems to handle OPTIONS request with WCF. See http://blogs.msdn.com/b/carlosfigueira/archive/2012/05/15/implementing-cors-support-in-wcf.aspx – jbl Jun 27 '13 at 08:31

0 Answers0