Messiah
❔ Storing static data
I'm working with lots of static data (best example I can think of are items in a game), would you store this data in a struct, static classes, or what?
I'm mainly looking for performance and best practices. How would you implement this? I'd appreciate some keywords I could google as well, not sure what to search for this.
28 replies
❔ Singleton/semaphor EF Core
I need to make sure only one instance of EF Core (db context) runs at once, otherwise if two requests arrive at the same time, they'll both search for the username in the DB, see that they don't exist and try to create them, instead of redirecting the second request to a login logic.
How can something like this be accomplished? There's a billion different ways to implement this and I'm not entirely sure which one is the best/simplest for my use case. There's blocking collection, dictionaries, semaphores, semaphoreSlim, queues, concurrentqueues, list goes on.
12 replies
❔ EFCore finding a single entry
I need to find an entry in the database or create if it doesn't exist. I can't see any mistakes in my code, yet when I process many chess matches, when an user exists in multiple matches, EF Core keeps adding multiple entries of this same user. Can you see any mistakes in this code? 4 hours of debugging this 😦
8 replies
❔ Dealing with parallel http requests in an API
I have an API that receives many requests before they've concluded executing in the api. This causes unwanted behaviour such as writing twice to the database with the same PK.
What options do I have to fix this? I'm honestly looking for the easiest to implement solution, at this point I don't care about good practices or performance, except for only the ASP.NET controller having to be async (so I can't drop all requests while I process one).
I've thought about putting requests in queues or channels, also thought about implementing some kind of lock that doesn't drop incoming requests (if that's a thing).
Ideas?
25 replies
❔ OSS/Examples for JSON Deserialization?
I'm working on a mid-sized application that does a lot of json deserialization from third party API responses. Does anyone knows where I could find some OSS projects that use json document/node that I could use as reference for advanced json processing?
18 replies
❔ How do yall do HttpClient tokens?
I have a typed http client factory in ASP.NET that I need an OAuth2 token to be shared amongst this type.
Is there a library for helping with this or do I have to code it manually?
I'm guessing I can put the token in a memory cache, but how do I add the token to each request? Google-fu told me I could use a middleware, but this would regenerate the token with each request, instead of only when it's needed.
4 replies
❔ Two MS Graph Clients on same application
We all know you can DI graph into the application through
AddMicrosoftGraph
, but I'm trying to have two graph clients (from different AAD tenants), the docs doesn't explain how to do this. Could someone point me in the right direction?2 replies
❔ Razor pages redirect
How do you make a form redirect to a page, and pass a value to it?
My entire application is routed as such: "www.site.com/thepage/thequery". How do I get data from the form and pass to the page it, with the query?
I can't get it to work without with the url formatted like that
9 replies
❔ credentials in git
so I been using git locally and in a private repo, and I didn't exclude the account credentials from the repo. But if I add the credentials file to the .ignore, then push and make the repo public, the old file will still show up in the change history, yeah?
How do I get rid of the existence of this file entirely?
3 replies
❔ How to properly redirect in Razor Pages?
I'm redirecting w/ variables using:
1.
<a asp-page="Stats" asp-route-qurl="@j">button</a>
redirects to /Stats page, also sending a string to the page.
2. /Stats page calls a 3rd party API using the string
3. /Stats renders itself using response from 3rd party API
But this is causing me to lose my session tokens. Every page is properly DI'd with downstreamWebApi
. Do I have to add some attributes to get .AddDownstreamWebApi()
to work with every page, or am I just redirecting wrong?2 replies
❔ MVC models conflicting names
I'm consuming a big api from azure, and the child model classes I'm building have conflicting names after I paste classes as JSON.
Example:
I only need the root node to be public, but it doesn't seem like a good solution to make the child nodes private since i'll need to access them at some point.
Is there a way to make child nodes only accessible if I write out the root node name first?
5 replies