I have a 9.5.1 localhost WebMethod (works from aspx test page using JQuery). When I call it from a winform app It gets {"Response status code does not indicate success: 500 (Internal Server Error)."}

Winform Calling code is:

public static async Task<int> VerifyUpdateProductImages(string isbn)
            var returnInt = -1;
            var testUri = "http://localhost:52561/KboAjaxBase.asmx/VerifyUpdateProductImages";
            using (var client = new HttpClient())
                client.DefaultRequestHeaders.Add("X-Requested-With", "XMLHttpRequest");
                    new MediaTypeWithQualityHeaderValue("application/json"));
                var ajaxCallParams = new AjaxCallParams(Constants.VerifyUpdateProductImages, "none", null);
                var json = JsonConvert.SerializeObject(ajaxCallParams);
                using (var stringContent = new StringContent(json, Encoding.UTF8, "application/json"))
                    using (var response = await client

                        if (response.IsSuccessStatusCode)
                            var returnValue = await response.Content.ReadAsStringAsync();
                            int.TryParse(returnValue, out returnInt);
                return returnInt;

WebMethod is:


public AjaxCallParams VerifyStoreImagesOnServer(AjaxCallParams ajaxCallParams)
    int imagesCreated = -1; 
    AjaxCallParams returnParams = new AjaxCallParams(ajaxCallParams.Request, "",null);
    string isbn = ajaxCallParams.Data.ToString();
    using (var db = new DataAccess())
        var productId = db.GetProductIdForSku(isbn);
        if (productId != 0)
            imagesCreated = ImageFuncsServer.VerifyStoreImagesOnServer(isbn);
        returnParams.Data = imagesCreated.ToString();
    return returnParams;


in General by (380 points)

2 Answers

0 votes
To start with are we talking about a .aspx page or a .asmx service? Cause it looks like you are using a web service with the client code.

As for the error with the webservice without knowing about how AjaxCallParams and StaticState are setup code wise it is a bit hard for me to say. Cause without knowing the rest of the code it confusing as to why the isbn just not a string paramater in the service method to begin with. Either way it looks like you need to be running a debugger in visual studio on the website. That way you can see were you are getting the 500 response from.
by (5k points)
0 votes

Is your TestURI incorrect? It's a hyperlink html vs just URL?

Thank you,
Compunix, LLC (Phoenix, AZ)
AspDotNetStorefront Development Partner and Reseller since 2005
 AspDotNetStorefront add-ons and plugins : http://www.ecommercecartmods.com
  * Searching Filtering, Single Signons, Reviews Ratings, Reports, Integrations
 Complete Automotive Solution : http://www.autopartsshoppingcart.com
  * Auto + Aftermarket Parts solution
 Unlimited Custom Development : http://www.compunix.us/t-unlimited-custom-development.aspx
  * Unlimited with Quick turn-arounds!
by (6.9k points)