Search code examples
c#asp.netweb-servicesasmx

ASP.NET Web Pages Web Service Calls Redirecting to about:blank


I just reformatted my computer and re-installed everything. I enabled IIS, the website I am working on in Visual Studio 2015 is working fine, even with the SQL database. However, none of my web services are returning any data. The web services are all .asmx web services. I tried going to the .asmx page itself and invoking the web methods, but all that happens is I am redirected to about:blank. This is after I successfully reach the asmx page, but after I click invoke on a specific web service.

Furthermore, I have Fiddler running, and there isn't even an http request created at all. I have tried invoking the web services using the asmx page, the ajax control toolkit, and jQuery AJAX calls, all of which don't even produce an http request. The website is running in IIS.

Any idea what could cause this behavior?

EDIT

Here is some sample code.

<script type="text/javascript">
    $(document).ready(function () {
        debugger;
        var vendorId = 5;
        var postData = JSON.stringify({ vendorId: vendorId });

        $.ajax({
            type: "POST",
            url: "../WebServices/BuildMaterialService.asmx/GetPurchaseOrderItemsByVendorId",
            data: postData,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            timeout: 5000,
            success: function (data, textStatus, jqSHR) {
                debugger;
                data = data.d;
                alert(data);
            },
            error: function (request, status, error) {
                debugger;
                if (status == "timeout")
                    alert("A timeout occurred. Please try again.");
                else
                    alert("An unknown error occurred. Please try again.");
            }
        });
    });
</script>

Yes, jQuery is already loaded and working. The first debugger is hit, vendorId and postData are set correctly. The AJAX call never generates an HTTP request in Fiddler. In fact, it goes to the AJAX call, and when I hit F10, the next step is in some other background code. I'll let javascript run again and it stops again at the debugger command in the error function.

Again, this code has been working perfectly fine for 3 years now, it only stopped working after reformatting. The code is correct, so the error might be from IIS.

I'm trying to narrow down why, but actually that line var vendorId = 5; in my real code is replaced with var vendorId = Number($('#ddlVendors :selected').val()); - this fails and goes immediately to the error function in the AJAX call without ever getting to the AJAX command. If I go in to the console and write the same line of code but change the variable name it works perfectly fine var abc = Number($('#ddlVendors :selected').val()); - abc is set correctly here. It isn't anything to do with the variable name vendorId as I went in to the code and changed vendorId to abc and the same error happens. Even in the console, EVEN BEFORE that variable declaration is called (paused on debugger just before), I cannot declare a variable of whatever name I put there and assign the value. i.e. var vendorId = 5; fails but var blabla = 5;

Sorry this is long and confusing, but it's baffling me and hard to describe.

EDIT 2

I noticed that in IE it actually is successful. I took out the line dataType: 'json', which changed the behavior in Chrome so that it doesn't go to the error function, but rather the success function; however, the data is not actually returned from the server. Fiddler does show the http post from IE, but none exists from Chrome.

Furthermore, still in IE the web service requests via the ajax toolkit are not working. I have noticed people saying to switch from using <asp:ScriptManager to <ajaxToolkit:ToolkitScriptManager. I don't know why suddenly after a reformat this would be necessary but I tried it. The result is I get an error Could not load file or assembly 'AjaxMin, Version=4.97.4951.28478, Culture=neutral, PublicKeyToken=21ef50ce11b5d80f' or one of its dependencies. The system cannot find the file specified. The response from people online seems to be to install AjaxMin from NuGet. I did this but I still don't get the AjaxMin.dll file and it isn't installing the correct version. I tried using the command Install-Package AjaxMin -Version 4.97.4951.28478 but it gives an error that it can't find that package. I'm not sure why that file is even being requested as I don't see any reference to AjaxMin anywhere in my project directory.

I even downloaded the AjaxControlToolkit from https://github.com/DevExpress/AjaxControlToolkit/ and built it on my machine. I ran the sample site and went to cascading drop down samples and it doesn't work in Chrome, but does in IE. This is using IIS Express.


Solution

  • This boiled down to 2 issues.

    1. When I opened the solution for the first time Visual Studio had re-downloaded many of the packages and replaced the dlls I had in the bin folder. The only problem was the AjaxControlToolkit.dll was the wrong version. I copied the older version that I had from the staging server and it fixed the issue with the ajax control toolkit cascading dropdowns in IE.

    2. Chrome still didn't work at all for cascading dropdowns or simple jQuery AJAX calls. This ended up being due to my ad blocker extension (Stands) blocking the script from running. I whitelisted localhost and now Chrome works as well