Stefanidze
Stefanidze
CC#
Created by Stefanidze on 10/20/2024 in #help
✅ Working with npm in razor pages with vscode
I need to use npm for my project, and i don't quite understand how to add it t the solution. All of the info/tutorials i could find were about doing it with visual studio, and i could't find nothing useful about how to do it with cli. if i could get js/css files from npm standalone i could put them into the lib folder, but im entirely new to npm and don't know how to do it either. Can someone please help?
10 replies
CC#
Created by Stefanidze on 7/24/2024 in #help
✅ How do async methods handle references
You can't manually declare references (out and ref arguments) in async methods because of how async works (method returns before any work is done). It got me questioning the logic of it, because as far as i know, most of the argument passing in c# uses references, and by default passing an instance of a class uses a reference (except for records) Are all arguments in async methods treated as records and copied into a separate instance to later be used? Or it only affects the manual declaration of pointers? Why?
28 replies
CC#
Created by Stefanidze on 3/25/2024 in #help
✅ How can i bind a value to an item on render in blazor?
I use the following layout:
inject NevigationManager nav

<ul>
@for (int i = 0; i < ItemList.count, i++){
<li @onclick="() => redirect(i)">
@* some code *@
</li>
}
</ul>
@code{
public IReadOnlyCollection<Item>? ItemList;

//some code

void redirect(int index){
nav.NavigateTo($"/db?item={ItemList!.ElementAt(index).Id}");
}
inject NevigationManager nav

<ul>
@for (int i = 0; i < ItemList.count, i++){
<li @onclick="() => redirect(i)">
@* some code *@
</li>
}
</ul>
@code{
public IReadOnlyCollection<Item>? ItemList;

//some code

void redirect(int index){
nav.NavigateTo($"/db?item={ItemList!.ElementAt(index).Id}");
}
But when the user clicks on an item it tries to get next i value, for example if a database has 3 items (including null item) i will be 4, resulting in an IndexOutOfRangeException. How can i make i value somehow bind to the item on render in a way that i can get it in code?
12 replies
CC#
Created by Stefanidze on 3/22/2024 in #help
Can i use async/await in class constructors?
I want my class constructor to send data to the database, so every instance of the class is synced with the corresponding item in the database. The problem is that database uses async, and i want to wait for the database to process the request, to output unique id, for me to use it later. Is there any way i can do that?
6 replies
CC#
Created by Stefanidze on 12/31/2023 in #help
What is the up-to-date version of AspNet.WebAPI?
I am upgrading my console application to include Web Api, so i changed the sdk from Microsoft.NET.Sdk to Microsoft.NET.Sdk.Web, and this resulted in project restoring Microsoft.AspNet.WebApi and Microsoft.AspNet.WebApi.Cors. But now when i build or run my project i get warning NU1701 In the output it shows that it cannot restore these two packages with net8.0 but instead they work only with .NET framework. From this i assume that these packages are legacy and need to be replaced, but i couldn't find any information about it. Is there any up-to-date version, for example based on AspNetCore? I use VSCode. Full output of the warning
8 replies