gpt4 book ai didi

c# - 如何解释错误 'Client found response content type of ' text/html'..

转载 作者:IT王子 更新时间:2023-10-29 04:20:23 25 4
gpt4 key购买 nike

我正在使用 C# 并通过自动生成的 C# 代理对象连接到 WebService。我调用的方法可能会长时间运行,有时会超时。我收到不同的错误,有时我收到 System.Net.WebExceptionSystem.Web.Services.Protocols.SoapException。这些异常具有我可以查询的属性,以找到特定类型的错误,我可以从中向用户显示人性化版本。

但有时我只是得到一个InvalidOperationException,它有以下消息。有什么方法可以解释这是什么,而无需深入了解我认识的字符串,这感觉很脏,而且与国际化无关,错误消息可能会以不同的语言返回。

Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'.
The request failed with the error message:
--
<html>
<head>
<title>Request timed out.</title>
<style>
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Lucida Console";font-size: .9em}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
</style>
</head>

<body bgcolor="white">

<span><H1>Server Error in '/PerformanceManager' Application.<hr width=100% size=1 color=silver></H1>

<h2> <i>Request timed out.</i> </h2></span>

<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

<b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

<br><br>

<b> Exception Details: </b>System.Web.HttpException: Request timed out.<br><br>

<b>Source Error:</b> <br><br>

<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code>

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code>

</td>
</tr>
</table>

<br>

<b>Stack Trace:</b> <br><br>

<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code><pre>

[HttpException (0x80004005): Request timed out.]
</pre></code>

</td>
</tr>
</table>

<br>

<hr width=100% size=1 color=silver>

<b>Version Information:</b> Microsoft .NET Framework Version:2.0.50727.312; ASP.NET Version:2.0.50727.833

</font>

</body>
</html>
<!--
[HttpException]: Request timed out.
-->
--.

编辑:我对网络服务器上的方法进行了尝试。我已经调试了它,并且 web-server 方法返回(大约一分钟后),没有任何异常。我还在 Web 服务中添加了一个未处理的异常处理程序和一个没有命中的断点。 Web 服务一返回,我就在客户端收到此错误,而不是我预期的结果。

最佳答案

发生这种情况是因为您的 Web 服务中存在未处理的异常,并且 .NET 运行时吐出其 HTML 蓝屏死亡服务器错误/异常转储页面,而不是 XML。

由于您的 Web 服务的消费者期望的是 text/xml header ,但却得到了 text/html,因此它会抛出该错误。

您应该解决超时的原因(也许是冗长的 SQL 查询?)。

此外,结帐this blog post在 Jeff Atwood 的博客上,解释了实现全局未处理的异常处理程序和使用 SOAP 异常。

关于c# - 如何解释错误 'Client found response content type of ' text/html'..,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/115319/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com