Pascal
❔ Docker: Dotnet restore just loading
I don't think
/
is normal here, your project is definitely not in the root folder of the container. Your project files are instead copied to /src
, so it does not make sense to tell dotnet restore
to restore a project at /BackendForFrontend.csproj
when it is not there.35 replies
For-Loop doesnt work.
the issue with your code is that
threadCounter
, is sometimes unassigned. So the compiler does not know what to do when the value is unassigned and yet you are trying to access a value from it. you can fix this by assigning a default value to threadCounter
. Something like int threadCounter = 0
or whatever your default value is.72 replies
❔ Determine what variable is being referenced
You would have to use
Unsafe.AreSame<int>(ref someRef, ref someVar)
(https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.unsafe.aresame?view=net-7.0#system-runtime-compilerservices-unsafe-aresame-1(-0@-0@)) to compare the references in this case. You don't want to use ReferenceEquals(someRef, someVar)
due to boxing for value types.15 replies
❔ What is the appropriate way to confirm User ID for API
in your controller endpoint you have access to the
User
object. Which you can use to pass down the logged in user id User.FindFirstValue(ClaimTypes.NameIdentifier)
. If your service should only be used in an http scope, then you may go with one of the suggestions above.25 replies
✅ Containers orchestration
There are lots of content and topics to cover with container orchestration, since your aim is to learn you may want to consider the Kubernetes approach (it is the industry standard for container orchestration). On windows you can enable kubernetes using Docker Desktop and on linux you can install Minikube. Then again you will have to read through kubernetes docs, Getting Started. When you feel comfortable defining and deploying kubernetes resources, then you may want to take it a step further and try setting up a cluster.
7 replies
✅ Containers orchestration
Is HA (High Availability) a requirement for your graduation project? Seems overkill, but the quickest solution is to use a cloud managed services like AKS (Azure Kubernetes Service), EKS (Amazon Kubernetes Service) or any other. But if this is just to run on your local machine then you may consider installing MiniKube and reading up on the Kubernetes docs.
7 replies
❔ What is the appropriate way to confirm User ID for API
Yes something may or may not be wrong with this service depending on your DI registration. If
CategoryService
is registered as a Singleton
(which I assume you are from your use of IHttpContextAccessor
) then this code breaks, _userId
will always have the same value after initial initialization. HttpContext
is only present in an Http scope, so if you initialize CategoryService
outside of an Http scope, _httpContextAccessor.HttpContext
will return null. Also the [Authorize]
attribute here does nothing, you need to add it to your endpoint: Http endpoint, controller endpoint, signalR or gRPC.25 replies