简体   繁体   English

ASP.NET网页Web服务调用重定向到about:blank

[英]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. 我启用了IIS,即使在使用SQL数据库的情况下,我在Visual Studio 2015中工作的网站也能正常工作。 However, none of my web services are returning any data. 但是,我的Web服务都没有返回任何数据。 The web services are all .asmx web services. Web服务都是.asmx Web服务。 I tried going to the .asmx page itself and invoking the web methods, but all that happens is I am redirected to about:blank. 我尝试转到.asmx页面本身并调用Web方法,但是发生的所有事情都是将我重定向到about:blank。 This is after I successfully reach the asmx page, but after I click invoke on a specific web service. 这是在我成功到达asmx页面之后,但是在单击特定Web服务上的调用之后。

Furthermore, I have Fiddler running, and there isn't even an http request created at all. 此外,我正在运行Fiddler,甚至根本没有创建一个http请求。 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. 我尝试使用asmx页面,ajax控件工具包和jQuery AJAX调用来调用Web服务,所有这些甚至都不会产生http请求。 The website is running in IIS. 该网站正在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. 是的,jQuery已经加载并且可以使用了。 The first debugger is hit, vendorId and postData are set correctly. 命中第一个调试器,正确设置了vendorId和postData。 The AJAX call never generates an HTTP request in Fiddler. AJAX调用永远不会在Fiddler中生成HTTP请求。 In fact, it goes to the AJAX call, and when I hit F10, the next step is in some other background code. 实际上,它转到了AJAX调用,当我按下F10时,下一步是其他一些后台代码。 I'll let javascript run again and it stops again at the debugger command in the error function. 我将让javascript重新运行,并在error函数中的debugger命令处再次停止。

Again, this code has been working perfectly fine for 3 years now, it only stopped working after reformatting. 再次,该代码已经完美运行了3年,仅在重新格式化后才停止工作。 The code is correct, so the error might be from IIS. 该代码是正确的,因此错误可能是来自IIS。

I'm trying to narrow down why, but actually that line var vendorId = 5; 我试图缩小原因,但实际上那行var vendorId = 5; in my real code is replaced with var vendorId = Number($('#ddlVendors :selected').val()); 在我的真实代码中替换为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. -这将失败,并且会立即进入AJAX调用中的错误功能,而无需获取AJAX命令。 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()); 如果我进入控制台并编写了相同的代码行,但是更改了变量名,则可以正常工作var abc = Number($('#ddlVendors :selected').val()); - abc is set correctly here. -此处的abc设置正确。 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. 当我进入代码并将vendorId更改为abc时,与变量名称vendorId无关,并且会发生相同的错误。 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. 即使在控制台中,即使在调用变量声明之前(之前在调试器上暂停了),我也无法声明我在其中放置的任何名称的变量并赋值。 ie var vendorId = 5; var vendorId = 5; fails but var blabla = 5; 失败,但var blabla = 5;

Sorry this is long and confusing, but it's baffling me and hard to describe. 抱歉,这很长且令人困惑,但这使我感到困惑,难以描述。

EDIT 2 编辑2

I noticed that in IE it actually is successful. 我注意到在IE中它实际上是成功的。 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; 我取出了dataType: 'json',它更改了Chrome中的行为,因此它不会转到错误函数,而是转到成功函数; however, the data is not actually returned from the server. 但是,实际上并没有从服务器返回数据。 Fiddler does show the http post from IE, but none exists from Chrome. Fiddler确实显示了IE的http帖子,但Chrome没有显示该帖子。

Furthermore, still in IE the web service requests via the ajax toolkit are not working. 此外,仍然在IE中,通过ajax工具包进行的Web服务请求无法正常工作。 I have noticed people saying to switch from using <asp:ScriptManager to <ajaxToolkit:ToolkitScriptManager . 我注意到有人说要从使用<asp:ScriptManager切换到<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. 结果是我得到一个错误, 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. 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. 网上人们的回应似乎是从NuGet安装AjaxMin。 I did this but I still don't get the AjaxMin.dll file and it isn't installing the correct version. 我这样做了,但是我仍然没有得到AjaxMin.dll文件,它没有安装正确的版本。 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. 我尝试使用命令Install-Package AjaxMin -Version 4.97.4951.28478但是它给出了一个错误,即找不到该软件包。 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. 我不确定为什么甚至要请求该文件,因为我在项目目录中的任何地方都看不到对AjaxMin的引用。

I even downloaded the AjaxControlToolkit from https://github.com/DevExpress/AjaxControlToolkit/ and built it on my machine. 我什至从https://github.com/DevExpress/AjaxControlToolkit/下载了AjaxControlToolkit并将其构建在我的机器上。 I ran the sample site and went to cascading drop down samples and it doesn't work in Chrome, but does in IE. 我运行了示例站点,然后进行级联下拉示例,它在Chrome中不起作用,但在IE中起作用。 This is using IIS Express. 这是使用IIS Express。

This boiled down to 2 issues. 归结为2个问题。

  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. 当我第一次打开解决方案时,Visual Studio重新下载了许多软件包,并替换了bin文件夹中的dll。 The only problem was the AjaxControlToolkit.dll was the wrong version. 唯一的问题是AjaxControlToolkit.dll版本错误。 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. 我复制了我从登台服务器上获得的旧版本,它解决了IE中的Ajax控件工具包级联下拉菜单的问题。

  2. Chrome still didn't work at all for cascading dropdowns or simple jQuery AJAX calls. 对于级联的下拉菜单或简单的jQuery AJAX调用,Chrome仍然根本不起作用。 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 我将本地主机列入白名单,现在Chrome也可以正常使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM