13eck
13eck
Explore posts from servers
CC#
Created by 13eck on 9/8/2023 in #help
❔ Can I serve a static file using a wildcard route?
Much appreciated!
32 replies
CC#
Created by 13eck on 9/8/2023 in #help
❔ Can I serve a static file using a wildcard route?
Just for completeness sake, what would a controller-based code snippet look like? If it's not too much trouble
32 replies
CC#
Created by 13eck on 9/8/2023 in #help
❔ Can I serve a static file using a wildcard route?
Awesome, you've been a big help. Thank you so much!
32 replies
CC#
Created by 13eck on 9/8/2023 in #help
❔ Can I serve a static file using a wildcard route?
I thought that Results.File() was for downloading, didn't think to try it to render a file >_<
32 replies
CC#
Created by 13eck on 9/8/2023 in #help
❔ Can I serve a static file using a wildcard route?
Exactly, yes
32 replies
CC#
Created by 13eck on 9/8/2023 in #help
❔ Can I serve a static file using a wildcard route?
The client needs to know, so JS can fetch character with id 38
32 replies
CC#
Created by 13eck on 9/8/2023 in #help
❔ Can I serve a static file using a wildcard route?
My thought process was the user would go to https://example.com/character/38, it'd give 'em the character.html page with just the static content, use JS fetch() to hit the DB endpoints to get JSON data, then use that data to populate the HTML page with the actual info
32 replies
CC#
Created by 13eck on 9/8/2023 in #help
❔ Can I serve a static file using a wildcard route?
Yeah, this
32 replies
CC#
Created by 13eck on 9/8/2023 in #help
❔ Can I serve a static file using a wildcard route?
No, I want to serve the static file. Then when the client downloads the file they also download the JS files that do the database querying to populate the info client-side
32 replies
CC#
Created by 13eck on 9/8/2023 in #help
❔ Can I serve a static file using a wildcard route?
I don't feel like SSR is needed for something as light-weight as "character name, list character skills, etc"
32 replies
CC#
Created by 13eck on 9/8/2023 in #help
❔ Can I serve a static file using a wildcard route?
No, b/c it's client-side 😉
32 replies
CC#
Created by 13eck on 9/8/2023 in #help
❔ Can I serve a static file using a wildcard route?
The route is dynamic only insofar that there's an Id on the end. The character sheet is the same regardless of what character it is, just the details are different. So I want to use one file as the template for the character sheet and then use JS to fetch the character's info from the database and update the page with the appropriate data. It's like if I did https://example.com/character?id=38 but with https://example.com/character/38 instead.
32 replies
CC#
Created by 13eck on 7/22/2023 in #help
❔ Filter a ConcurrentDictionary
I'll have a look, thanks!
15 replies
CC#
Created by 13eck on 7/22/2023 in #help
❔ Filter a ConcurrentDictionary
Thanks for confirming! I recently started C# after being a front-end dev so I'm still learning 😁
15 replies
CC#
Created by 13eck on 7/22/2023 in #help
❔ Filter a ConcurrentDictionary
My initial code did two foreach loops, one to get the expired items and one to remove them, but thought I should do a Select to cut down on the number of iterations:
List<KeyValuePair<string, UserCacheItem>> Items = new();
foreach (var item in _cache)
{
if (item.Value.Expiry < DateTimeOffset.Now) Items.Add(item);
}
foreach (var item in Items)
{
_cache.TryRemove(item);
}
List<KeyValuePair<string, UserCacheItem>> Items = new();
foreach (var item in _cache)
{
if (item.Value.Expiry < DateTimeOffset.Now) Items.Add(item);
}
foreach (var item in Items)
{
_cache.TryRemove(item);
}
15 replies