circles.png
circles.png
CC#
Created by circles.png on 3/25/2023 in #help
❔ vscode (mac) does not recognise things in a new maui project
37 replies
CC#
Created by circles.png on 2/23/2023 in #help
❔ Can someone explain asynchronous code?
I've read the overview with the breakfast analogy on the Microsoft docs for .NET, and still don't get - how to use it (and efficiently) - how .NET is able to do many things on one thread at the same time There is one way I think I understand. - callbacks - when a task is done, call a function to deal with the result - probably not very good - JS thing
52 replies
CC#
Created by circles.png on 1/20/2023 in #help
❔ ASP.NET Core (in container) is trying to connect to another container via localhost
The connection string specifies mongo as the hostname, but the API still tries to connect to [::1] which is the loopback IPv6 address (localhost) I have a Docker Compose file with containers - backend: ASP.NET Core web API - mongo: MongoDB which looks like this:
version: '3.4'

services:
backend:
image: home-api
ports:
- "2154:2154"
build:
context: ./api
dockerfile: ./api/Dockerfile

mongo:
image: mongo
restart: always
ports:
- "2155:27017"
volumes:
- ./Data:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: home-api
MONGO_INITDB_ROOT_PASSWORD: home-api
version: '3.4'

services:
backend:
image: home-api
ports:
- "2154:2154"
build:
context: ./api
dockerfile: ./api/Dockerfile

mongo:
image: mongo
restart: always
ports:
- "2155:27017"
volumes:
- ./Data:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: home-api
MONGO_INITDB_ROOT_PASSWORD: home-api
With the API, I followed two tutorials: - https://learn.microsoft.com/en-us/aspnet/core/web-api/?WT.mc_id=dotnet-35129-website&view=aspnetcore-7.0 - https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mongo-app?view=aspnetcore-7.0&tabs=visual-studio-code I then containerized it and started mongod in a ./Data directory. When connecting to the database (on the mongo container) with this appsettings.json
{
"HomeDatabase": {
"ConnectionString": "mongodb://home-api:home-api@mongo:27017/Home.Users?authSource=admin",
"DatabaseName": "Home",
"UsersCollectionName": "Users"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
{
"HomeDatabase": {
"ConnectionString": "mongodb://home-api:home-api@mongo:27017/Home.Users?authSource=admin",
"DatabaseName": "Home",
"UsersCollectionName": "Users"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
I recieve an error from the backend container. (attached) New to MongoDB, Docker, and ASP.NET. Let me know if you want any additional information.
41 replies
CC#
Created by circles.png on 1/20/2023 in #help
❔ "Cannot assign requested address [::1]:27017" when connecting to MongoDB on Docker.
I have a Docker Compose file with containers - backend: ASP.NET Core web API - mongo: MongoDB which looks like this:
version: '3.4'

services:
backend:
image: home-api
ports:
- "2154:2154"
build:
context: ./api
dockerfile: ./api/Dockerfile

mongo:
image: mongo
restart: always
ports:
- "2155:27017"
volumes:
- ./Data:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: home-api
MONGO_INITDB_ROOT_PASSWORD: home-api
version: '3.4'

services:
backend:
image: home-api
ports:
- "2154:2154"
build:
context: ./api
dockerfile: ./api/Dockerfile

mongo:
image: mongo
restart: always
ports:
- "2155:27017"
volumes:
- ./Data:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: home-api
MONGO_INITDB_ROOT_PASSWORD: home-api
With the API, I followed two tutorials: - https://learn.microsoft.com/en-us/aspnet/core/web-api/?WT.mc_id=dotnet-35129-website&view=aspnetcore-7.0 - https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mongo-app?view=aspnetcore-7.0&tabs=visual-studio-code I then containerized it and started mongod in a ./Data directory. When connecting to the database (on the mongo container) with this appsettings.json
{
"HomeDatabase": {
"ConnectionString": "mongodb://home-api:home-api@mongo:27017/Home.Users?authSource=admin",
"DatabaseName": "Home",
"UsersCollectionName": "Users"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
{
"HomeDatabase": {
"ConnectionString": "mongodb://home-api:home-api@mongo:27017/Home.Users?authSource=admin",
"DatabaseName": "Home",
"UsersCollectionName": "Users"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
I recieve an error from the backend container. (attached) New to MongoDB, Docker, and ASP.NET. Let me know if you want any additional information.
3 replies