asp.net - 1-2 天后发生 URL 意外以 '/Convert' 结尾的请求格式无法识别

标签 asp.net web-services https xmlhttprequest asmx

我正在使用 Microsoft.XMLHTTP 调用来调用 Web 服务:

var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST", "/xxx/Converter.asmx/Convert", false);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send("conversionFolder=" + escape(conversionFolder));
if (xmlhttp.status == 200) {
  xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  xmlDoc.async = "false";
  xmlDoc.loadXML(xmlhttp.responseText);
  ... more stuff ...
  return str;
}
else {
  alert(xmlhttp.statusCode + " - " + xmlhttp.statusText);
}

当我记得在本地 web.config 中添加 HttpPost 协议(protocol)时,一切正常:
<?xml version="1.0"?>
<configuration>
  <appSettings/>
  <connectionStrings/>
  <system.web>
    <webServices>
      <protocols>
        <add name="HttpPost"/>
      </protocols>
    </webServices>
    <compilation debug="false"></compilation>
  </system.web>
  <system.codedom>
  </system.codedom>
  <!--
    The system.webServer section is required for running ASP.NET AJAX under Internet
    Information Services 7.0.  It is not necessary for previous version of IIS.
  -->
  <system.webServer>
  </system.webServer>
</configuration>

但是在一台生产服务器上运行 1-2 天后它会失败。在 asp.net 进程被回收后它工作正常。它工作了1-2天,然后失败了:
Exception information:
Exception type: InvalidOperationException
Exception message: Request format is unrecognized for URL unexpectedly ending in '/Convert'.

Request information:
Request URL: https://xxx/xxx/converter.asmx/Convert
Request path: /xxx/converter.asmx/Convert
User host address: 195.50.35.4
User: extranet\kbk
Is authenticated: True
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE

Thread information:
Thread ID: 14
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath)
at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

为什么要等2天才失败?我能做些什么来防止它失败?
这与此服务器以 HTTPS 模式运行有关吗?

最佳答案

什么是点网框架? IIS 6 还是 7?
您是否尝试添加 <add name="HttpGet"/>在协议(protocol)部分。似乎有些人已经通过该修复解决了这个问题。 (但不是所有人)
link 1
link 2
还要检查您在哪里部署站点。它是在您的 Web 服务器的根级别还是虚拟文件夹中。有时它可能会从父级站点或 machine.config 文件中继承一些配置值。

否则,它可能与您的代码中的一些内存泄漏有关。你如何处理加载的 XML。
我还假设您正在解析一个有效的 XML。

关于asp.net - 1-2 天后发生 URL 意外以 '/Convert' 结尾的请求格式无法识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6460385/

相关文章:

docker - 如何设置 https 到 nginx docker 容器 (laradock)?

javascript - 在 Javascript 中访问 TimePicker 值

html - 希望页脚留在底部,但不是绝对的

c# - 当用户向其中输入数据时,TextBox.Text 为 null

php - 如何使用 PEAR PHP Http_Request2 库在 PUT 方法中发送数据

ios - 来自 iOS 应用程序的自签名 SSL 证书信任

c# - XML 将所有子元素重命名为相同的标签名称

c - 使用 LoadRunner/Performance Center 测试 Web 服务

java - Apache cxf java-first 和 SOAP 模块 npm

javascript - 带有 If-Match header 的 Node.js PATCH 请求