I created a WebApi Server in Visual Studio with c#. A client application calls the service with:
string restMethod = "api/ClientImport/GetOffene/";
var url = new Uri(_client.BaseAddress.ToString() + restMethod + _credString);
HttpResponseMessage response = await _client.GetAsync(url);
The first time it works fine. If I try to use this service from the client a second time it will always fail with an ServerProtocolViolation exception.
If I try it again it works fine again. Then on second attempt the same error occurs. Also when I try to call to different methods, the second one will always crash.
This is the exception:
- ex Count = 1 System.Exception {System.AggregateException}
- Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal} HResult -2146233088 int HelpLink null string
- InnerException {"Fehler beim Senden der Anforderung."} System.Exception {System.Net.Http.HttpRequestException}
- Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal} Count 0 int IsFixedSize false bool IsReadOnly false bool IsSynchronized false bool
- Keys {System.Collections.ListDictionaryInternal.NodeKeyValueCollection} System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection} SyncRoot {object} object
- Values {System.Collections.ListDictionaryInternal.NodeKeyValueCollection} System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
- Nicht öffentliche Member
- Ergebnisansicht Beim Aufklappen der Ergebnisansicht wird IEnumerable aufgeführt.
HResult -2146233088 int HelpLink null string- InnerException {"Der Server hat eine Protokollverletzung ausgeführt.. Section=ResponseStatusLine"} System.Exception {System.Net.WebException}
- Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal} HResult -2146233079 int HelpLink null string
- InnerException null System.Exception Message "Der Server hat eine Protokollverletzung ausgeführt.. Section=ResponseStatusLine" string Response null System.Net.WebResponse Source "System" string StackTrace " bei System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)\r\n bei System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)" string Status ServerProtocolViolation System.Net.WebExceptionStatus
- TargetSite {System.Net.WebResponse EndGetResponse(System.IAsyncResult)} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo} Attributes Public | Virtual | HideBySig System.Reflection.MethodAttributes CallingConvention Standard | HasThis System.Reflection.CallingConventions ContainsGenericParameters false bool
- CustomAttributes Count = 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 bool IsGenericMethod false bool IsGenericMethodDefinition false bool IsHideBySig true bool IsPrivate false bool IsPublic true bool IsSecurityCritical true bool IsSecuritySafeCritical true bool IsSecurityTransparent false bool IsSpecialName false bool IsStatic false bool IsVirtual true bool MemberType Method System.Reflection.MemberTypes MetadataToken 100665886 int
- MethodHandle {System.RuntimeMethodHandle} System.RuntimeMethodHandle MethodImplementationFlags IL System.Reflection.MethodImplAttributes
- Module {System.dll} System.Reflection.Module {System.Reflection.RuntimeModule} Name "EndGetResponse" string
- 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 Member
- Statische Member
- Nicht öffentliche Member
Message "Fehler beim Senden der Anforderung." string Source "mscorlib" string StackTrace " bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n bei System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n bei DDS.xxx.Client.Engine.RestApiConnector.d__6.MoveNext() in C:\Projekte\Client\DDS.xxx.Client\DDS.xxx.Client.Engine\RestApiConnector.cs:Zeile 82." string- TargetSite {Void ThrowForNonSuccess(System.Threading.Tasks.Task)} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
- Statische Member
- Nicht öffentliche Member
- InnerExceptions Count = 1 System.Collections.ObjectModel.ReadOnlyCollection Message "Mindestens ein Fehler ist aufgetreten." string Source "mscorlib" string StackTrace " bei System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\r\n bei System.Threading.Tasks.Task
1.GetResultCore(Boolean waitCompletionNotification)\r\n bei System.Threading.Tasks.Task
1.get_Result()\r\n bei DDS.xxx.Client.Engine.RestApiConnector.GetOffeneForClientImport() in C:\Projekte\Client\DDS.xxx.Client\DDS.xxx.Client.Engine\RestApiConnector.cs:Zeile 69." string- TargetSite {Void ThrowIfExceptional(Boolean)} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
- Statische Member
- Nicht öffentliche Member
Anyone an idea want is my mistake?
Thank you in advance.