Free Code Snippets in C#, Net Framework, Office 365, ASP.Net,WPF, Visual Studio, SQL Server, Antivirus free
#

 

 

When executing the API request to an ASP.Net application, the feedback comes in the API client:

Could not get any response

This seems to be like an error connecting to http://localhost:51081/api/Projects. The response status was 0.

Check out the W3C XMLHttpRequest Level 2 spec for more details about when this happens.

 

Error in the test client Postman

 

Examination:

The error is caused when the ASP.Net application tries to access the database

// GET-all: api/Projects *List all Records

[HttpGet]

public IEnumerable<Project> Gettbl_Projects()

{

  return _context.tbl_Projects;

}

 

 

Reason:

In C # with applications that access SQL Client Server, for values that can become NULL, you must define the local variables Nullable.

 

Correction in C #

This means that you have to end the variables DateTime, Integer, and Double with a question mark in the local data variables

Like here:

public DateTime DtList { get; set; }

public DateTime? DtScan { get; set; }

 

String variables in C # are automatically nullable and therefore do not need any correction.

 

 

Error display in detail:

There is already an open DataReader associated with this Command which must be closed first.

 

source:

"System.Data.SqlClient"    string

 

 

 

Stack Trace on Connection

The stack trace incorrectly indicates an error with the SQL Connection.

StackTrace of the error

"   at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)\r\n   at System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String method, SqlCommand command)\r\n   at System.Data.SqlClient.SqlCommand.ValidateCommand(Boolean async, String method)\r\n   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)\r\n   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)\r\n   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)\r\n   at System.Data.Common.DbCommand.ExecuteReader()\r\n   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)\r\n   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.BufferlessMoveNext(Boolean buffer)\r\n   at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.MoveNext()\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.<_TrackEntities>d__17`2.MoveNext()\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()\r\n   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)\r\n   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)\r\n   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)\r\n   at System.Linq.SystemCore_EnumerableDebugView`1.get_Items()"          string

 

Mobile
»
Error: Identity column can not be updated, IDENTITY_INSERT is set to OFF
»
Asp Error: IDENTITY_INSERT OFF when accessing AspNetUsers registry
»
ASP IIS Error: 440.13 Not Found. upload file size is exceeded
»
InvalidOperationException: An exception occurred while reading a database value for property
»
A database operation failed while processing the request. SqlException: Invalid object name
»
InvalidOperationException: No database provider has been configured for this dbContext
»
NullReferenceException: Object reference not set to an instance of an object.
»
InvalidOperationException: The expected type was System.Boolean but the actual value was null.
»
Asp: InvalidOperationException: The model item passed into the ViewDataDictionary is of type
»
InvalidCastException: Unable to cast object of type System.Int32 to type System.Int64

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de