【发布时间】:2019-11-21 14:29:13
【问题描述】:
我用 c# 在 Visual Studio 中创建了一个 WebApi 服务器。 客户端应用程序调用服务:
string restMethod = "api/ClientImport/GetOffene/";
var url = new Uri(_client.BaseAddress.ToString() + restMethod + _credString);
HttpResponseMessage response = await _client.GetAsync(url);
第一次很好用。 如果我再次尝试从客户端使用此服务,它总是会因 ServerProtocolViolation 异常而失败。
如果我再试一次,它会再次正常工作。然后在第二次尝试时发生相同的错误。 此外,当我尝试调用不同的方法时,第二个总是会崩溃。
这是个例外:
- ex Count = 1 System.Exception {System.AggregateException}
- 数据 {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal} HResult -2146233088 int HelpLink 空字符串
- InnerException {"Fehler beim Sendend der Anforderung."} System.Exception {System.Net.Http.HttpRequestException}
- 数据 {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal} 计数 0 个整数 IsFixedSize false bool IsReadOnly false bool IsSynchronized false bool
- 键 {System.Collections.ListDictionaryInternal.NodeKeyValueCollection} System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection} SyncRoot {object} 对象
- 值 {System.Collections.ListDictionaryInternal.NodeKeyValueCollection} System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
- Nicht öffentliche 成员
- Ergebnisansicht Beim Aufklappen der Ergebnisansicht wird IEnumerable aufgeführt.
HResult -2146233088 int HelpLink 空字符串- InnerException {"Der Server hat eine Protokollverletzung ausgeführt.. Section=ResponseStatusLine"} System.Exception {System.Net.WebException}
- 数据 {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal} HResult -2146233079 int HelpLink 空字符串
- InnerException null System.Exception 消息“Der Server hat eine Protokollverletzung ausgeführt.. Section=ResponseStatusLine”字符串 响应空 System.Net.WebResponse 源“系统”字符串 StackTrace "北 System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)\r\n 北 System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)" 字符串 状态 ServerProtocolViolation System.Net.WebExceptionStatus
- TargetSite {System.Net.WebResponse EndGetResponse(System.IAsyncResult)} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo} 公共属性 |虚拟 | HideBySig System.Reflection.MethodAttributes 呼叫约定标准 | HasThis System.Reflection.CallingConventions ContainsGenericParameters false bool
- CustomAttributes 计数 = 1 System.Collections.Generic.IEnumerable {System.Collections.ObjectModel.ReadOnlyCollection}
- DeclaringType {Name = "HttpWebRequest" FullName = "System.Net.HttpWebRequest"} System.Type {System.RuntimeType} IsAbstract false bool IsAssembly false bool IsConstructor false bool IsFamily false bool IsFamilyAndAssembly false bool IsFamilyOrAssembly false bool IsFinal false 布尔值 IsGenericMethod false 布尔值 IsGenericMethodDefinition false bool IsHideBySig true bool IsPrivate false bool IsPublic true 布尔值 IsSecurityCritical true bool IsSecuritySafeCritical true bool IsSecurityTransparent false bool IsSpecialName false bool IsStatic false bool IsVirtual true bool MemberType 方法 System.Reflection.MemberTypes MetadataToken 100665886 int
- MethodHandle {System.RuntimeMethodHandle} System.RuntimeMethodHandle MethodImplementationFlags IL System.Reflection.MethodImplAttributes
- 模块 {System.dll} System.Reflection.Module {System.Reflection.RuntimeModule} 名称“EndGetResponse”字符串
- ReflectedType {Name = "HttpWebRequest" FullName = "System.Net.HttpWebRequest"} System.Type {System.RuntimeType}
- ReturnParameter {System.Net.WebResponse } System.Reflection.ParameterInfo {System.Reflection.RuntimeParameterInfo}
- ReturnType {Name = "WebResponse" FullName = "System.Net.WebResponse"} System.Type {System.RuntimeType}
- ReturnTypeCustomAttributes {System.Net.WebResponse } System.Reflection.ICustomAttributeProvider {System.Reflection.RuntimeParameterInfo}
- Nicht öffentliche 成员
- 国家统计局成员
- Nicht öffentliche 成员
消息“Fehler beim Senden der Anforderung”。细绳 源“mscorlib”字符串 StackTrace " 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\r\n 在 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult ()\r\n 贝 DDS.xxx.Client.Engine.RestApiConnector.d__6.MoveNext() 在 C:\Projekte\Client\DDS.xxx.Client\DDS.xxx.Client.Engine\RestApiConnector.cs:Zeile 82 。”字符串- TargetSite {Void ThrowForNonSuccess(System.Threading.Tasks.Task)} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
- 国家统计局成员
- Nicht öffentliche 成员
- InnerExceptions 计数 = 1 System.Collections.ObjectModel.ReadOnlyCollection 消息“Mindestens ein Fehler ist aufgetreten”。细绳 源“mscorlib”字符串 StackTrace " 在 System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\r\n 在 System.Threading.Tasks.Task
1.GetResultCore(Boolean waitCompletionNotification)\r\n bei System.Threading.Tasks.Task1.get_Result()\r\n 在 DDS.xxx.Client.Engine.RestApiConnector .GetOffeneForClientImport() 在 C:\Projekte\Client\DDS.xxx.Client\DDS.xxx.Client.Engine\RestApiConnector.cs:Zeile 69."字符串- TargetSite {Void ThrowIfExceptional(Boolean)} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
- 国家统计局成员
- Nicht öffentliche 成员
任何人想要的想法都是我的错误?
提前谢谢你。
【问题讨论】:
标签: c#