Jason/ajax web service call get redirected (302 Object moved) and then 500 unknow webservice name

Posted by user646499 on Stack Overflow See other posts from Stack Overflow or by user646499
Published on 2011-03-06T00:06:35Z Indexed on 2011/03/06 0:11 UTC
Read the original article Hit count: 361

Filed under:

I have been struggling with this for some times.. I searched around but didnt get a solution yet. This is only an issue on production server. In my development environment, everything works just fine.

I am using JQuery/Ajax to update product information based on product's Color attribute. for example, a product has A and B color, the price for color A is different from color B. When user choose different color, the price information is updated as well.

What I did is to first add a javascript function: function updateProductVariant() { var myval = jQuery("#<%=colorDropDownList.ClientID%>").val();

                    type: "POST",
                    url: "/Products.aspx/GetVariantInfoById",
                    data: "{variantId:'" + myval + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",

                    success: function (response) {
                        var obj = jQuery.parseJSON(response.d);

                        jQuery(".price .productPrice").text(obj.CurrentPrice);
                        jQuery(".price .oldProductPrice").text(obj.OldPrice);


Then I can register the dropdown list's 'onclick' event point to function 'updateProductVariant'

GetVariantInfoById is a WebGet method in the codebehind, its also very straightforward: [WebMethod] public static string GetVariantInfoById(string variantId) { int id = Convert.ToInt32(variantId); ProductVariant productVariant = IoC.Resolve().GetProductVariantById(id); string stockMessage = productVariant.FormatStockMessage(); StringBuilder oBuilder = new StringBuilder(); oBuilder.Append("{"); oBuilder.AppendFormat(@"""{0}"":""{1}"",", "StockMessage", stockMessage); oBuilder.AppendFormat(@"""{0}"":""{1}"",", "OldPrice", PriceHelper.FormatPrice(productVariant.OldPrice)); oBuilder.AppendFormat(@"""{0}"":""{1}""", "CurrentPrice", PriceHelper.FormatPrice(productVariant.Price)); oBuilder.Append("}"); return oBuilder.ToString(); }

All these works fine on my local box, but if i upload to the production server, catching the traffic using fiddler, /Products.aspx/GetVariantInfoById becomes a Get call instead of a POST

On my local box, HTTP/1.1 200 OK Server: ASP.NET Development Server/ Date: Thu, 03 Mar 2011 09:00:08 GMT X-AspNet-Version: 4.0.30319 Cache-Control: private, max-age=0 Content-Type: application/json; charset=utf-8 Content-Length: 117 Connection: Close

But when deployed on the host, it becomes HTTP/1.1 302 Found Proxy-Connection: Keep-Alive Connection: Keep-Alive Content-Length: 186 Via: 1.1 ADV-TMG-01 Date: Thu, 03 Mar 2011 08:59:12 GMT Location: http://www.pocomaru.com/Products.aspx/GetVariantInfoById/default.aspx Server: Microsoft-IIS/7.0 X-Powered-By: ASP.NET

then of course, then it returns 500 error title>Unknown web method GetVariantInfoById/default.aspx.
Parameter name: methodName

Can someone please take a look? I think its some configuration in the production server which automatially redirects my webservice call to some other URL, but since the product server is out of my control, i am seeking a local fix for this. Thanks for the help!

© Stack Overflow or respective owner

Related posts about web-services

Related posts about jquery-ajax