ASP.NET Core | Issue with in-memory data removal
Hey there, I am currently trying to make a backend service for my chess game made in Next.js as an internship project. I am most likely struggling with some basic concept I can't dig up any info about. Regarding the main issue, I have made a controller that handles:
A) GET request which returns the current chessboard state
B) POST request which returns the default chessboard state
C) POST request which returns the chessboard state after the piece moved
D) DELETE request which returns the chessboard state after removing piece
The problem occurs when I am trying to delete any piece using request D. The response that's being returned is correct, but right after when I try to fetch the chessboard with request A the seemingly deleted data is still present there.
9 Replies
if your repository is scoped, modifying
_pieces
isn't going to do anything useful because its going to be reset to the default configuration each requestAlright this actually might be the problem
But how come the post requests behave as they are supposed to then
It is currently bugging me
they "work" because they return the state after modifying it. But, if you posted something again, the previous post didn't actually happen because of the same issue.
Fair enough
That's actually really informative
Thank you
Then I believe I am supposed to change UseScoped to UseTransient
And I should be fine?
you can try it and see. Might be helpful to know the differences between the different registration types
I just read about them
And it seems like it should update it
ye, well it did not update it
I have got no idea what to do then
i wonder if theres another registration type
AddSingleton apparently saves the data
I suppose my issue's fixed then
@Deluxe Anyways, thank you for your help
I appreciate it a lot