Hello,
Im running from Snap 2019 R2 #2323 the simplest datastore WebApi and performing the simplest GET from browser:
http://localhost:5000/api/department/retrieve
all ok.
When running from command prompt instead (same machine, same DB, same .NET core, same all)
C:\Program Files\dotnet\dotnet.exe .\WebApi\bin\Debug\netcoreapp2.1\WebApi.dll
the WebApi starts same way as in Snap console
Now listening on: http://localhost:5000
but the GET returns unhandled exception below.
C# forums suggest to upgrade to Microsoft.AspNetCore.App 2.2 (not willing to, as Snap #2323 depends on 2.1) or check https/http mismatch (not my case). Cant recall if I had same issue on Snap 2019 R1.
Any idea?
Best,
.m
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:5000/api/department/retrieve
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[3]
Route matched with {action = "Retrieve", controller = "Department"}. Executing controller action with signature Microsoft.AspNetCore.Mvc.ActionResult`1[DWNet.Data.IDataStore`1[WebApi.Models.Department]] Retrieve() on controller WebApi.Controllers.DepartmentController (WebApi).
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
Executed action WebApi.Controllers.DepartmentController.Retrieve (WebApi) in 10.768ms
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HM0QM45DVLJ2", Request id "0HM0QM45DVLJ2:00000001": An unhandled exception was thrown by the application.
System.InvalidOperationException: Invalid connection string.
at SnapObjects.Data.AdoDbConnection..ctor(String connectionString)
at SnapObjects.Data.SqlServer.SqlServerDataContext.CreateAdoDbConnection(String connectionString)
indeed problem was the path, appsettings is in .\WebApi and therefore the execution had to be
C:\Program Files\dotnet\dotnet.exe .\bin\Debug\netcoreapp2.1\WebApi.dll
Best,
.m