iskander
iskander
CC#
Created by iskander on 1/24/2025 in #help
✅ How does server fetch information from the correct user?
Title says it all. i have a asp.net and have implemented all the api endpoints and all that. and up to this point i have just gave the users their ID in the DB and they required to give that ID back to get the information they want. but now im thinking this is not very secure way of doing it. i have set up authorization and whenever a user wants to fetch a user specific info then i check the given token to the token that is stored in the user info. if it matches then i'd return the requested stuff. is there a more elegant/secure way of handling this?
11 replies
CC#
Created by iskander on 1/6/2025 in #help
✅ My MAUI android app keeps hitting a breakpoint. but only in debug mode.
No description
9 replies
CC#
Created by iskander on 12/28/2024 in #help
✅ how should I deal with common/similar data types between the backend and front?
so i have two projects, one for my backend and the other for the front. now i have this ShopItemDTO in the backend and a very similar ShopItem class for the front. how
C#
namespace BuyMe.ServiceAPI.Models
{
public class ShopItemDTO
{
public string? Title { get; set; }
public float Rating { get; set; }
public int Price { get; set; }
public int Id { get; set; }
public bool IsOnSale { get; set; }

public ShopItemDTO() { }
//ShopItem is unique to the ServiceAPI
//it has the GUID of the seller that we dont want to share
public ShopItemDTO(ShopItem ShopItem) =>
(Title, Rating, Price, Id, IsOnSale) = (ShopItem.Title, ShopItem.Rating, ShopItem.Price, ShopItem.Id, ShopItem.IsOnSale);
}
}
C#
namespace BuyMe.ServiceAPI.Models
{
public class ShopItemDTO
{
public string? Title { get; set; }
public float Rating { get; set; }
public int Price { get; set; }
public int Id { get; set; }
public bool IsOnSale { get; set; }

public ShopItemDTO() { }
//ShopItem is unique to the ServiceAPI
//it has the GUID of the seller that we dont want to share
public ShopItemDTO(ShopItem ShopItem) =>
(Title, Rating, Price, Id, IsOnSale) = (ShopItem.Title, ShopItem.Rating, ShopItem.Price, ShopItem.Id, ShopItem.IsOnSale);
}
}
C#

namespace BuyMe.Models;

public class ShopItem_Front()
{
public string? Title { get; set; }
public float Rating {get; set;}
public int Price { get; set; }
public int Id { get; set; }
public bool IsOnSale { get; set; }
};
C#

namespace BuyMe.Models;

public class ShopItem_Front()
{
public string? Title { get; set; }
public float Rating {get; set;}
public int Price { get; set; }
public int Id { get; set; }
public bool IsOnSale { get; set; }
};
now im still early in the project so the class will probably have stuff added/removed from it and it be tedious to just reflect the changes from both classes. i was thinking i could maybe make the ShopItemDTO shared between the front and backend? but not sure if that would result in any security concerns? or some other problem that i dont know of 😅
12 replies
CC#
Created by iskander on 12/26/2024 in #help
best approach to handle a nested Scrolling views
No description
1 replies
CC#
Created by iskander on 1/19/2024 in #help
✅ (Avalonia) i dont get data binding
so im following the official tutorial on how to make a simple to-do app with avalonia. everything is fine and dandy but for whatever reason, trying to add a data context doesnt display my hardcoded values i set!
//MainWindow.axaml
<Window //boiler plate stuff
x:DataType="vm:MainWindowViewModel"
x:Class="testAvaloniaApplication1.Views.MainWindow"
Title="Iskander's great and grand TO-DO list">

<Views:ToDoListView DataContext="{Binding ToDoList}"/>

</Window>
//MainWindow.axaml
<Window //boiler plate stuff
x:DataType="vm:MainWindowViewModel"
x:Class="testAvaloniaApplication1.Views.MainWindow"
Title="Iskander's great and grand TO-DO list">

<Views:ToDoListView DataContext="{Binding ToDoList}"/>

</Window>
7 replies
CC#
Created by iskander on 11/16/2023 in #help
adding an element to a VerticalStackLayout in c# doesnt work as expected
hi! so i wanted to add a visual element (in my case a ContentView) to a VerticalStackLayout that i declared in the xaml file and exposed it via x:Name="Stack" i tried doing Stack.Add(MyView) in the cs file, it did add it, i checked the "count" variable in the stack and it did increment but it is not visible. when i resize the window the elements pops into existence. obviously i'd love it if it did render without needing to resize 😅
2 replies
CC#
Created by iskander on 8/8/2023 in #help
✅ TcpClient is connected to TcpListener but TcpListener isn't connected...
so this is how i accept clients which passes through with no issues. i've made to sure to catch any errors that could result from function and none is thrown...
public static async Task<bool> AcceptClient(CancellationToken Token)
{
if (!IsServer())
{
return false;
}
Server.Start();
TcpClient JoinedClient = await Server.AcceptTcpClientAsync(Token);
Server.Stop();

if (JoinedClient != null)
{
Clients.Add(JoinedClient);
return true;
}
else
{
return false;
}
}
public static async Task<bool> AcceptClient(CancellationToken Token)
{
if (!IsServer())
{
return false;
}
Server.Start();
TcpClient JoinedClient = await Server.AcceptTcpClientAsync(Token);
Server.Stop();

if (JoinedClient != null)
{
Clients.Add(JoinedClient);
return true;
}
else
{
return false;
}
}
this is how the client attempts to connect to the server. this result in a successful connection.
public static async Task<bool> JoinServer(string IpAddress)
{
Client = new TcpClient();

if (IPEndPoint.TryParse(IpAddress, out IPEndPoint Result))
{
Result.Port = Port;
await Client.ConnectAsync(Result);
return true;
}
else
{
Client = null;
return false;
}
}
public static async Task<bool> JoinServer(string IpAddress)
{
Client = new TcpClient();

if (IPEndPoint.TryParse(IpAddress, out IPEndPoint Result))
{
Result.Port = Port;
await Client.ConnectAsync(Result);
return true;
}
else
{
Client = null;
return false;
}
}
my pc is the server while my phone is the client. they're in the same network but i havent touched the firewall settings in my pc yet but i assume that wont cause this issue...
26 replies
CC#
Created by iskander on 8/7/2023 in #help
❔ ✅ (SOLVED) TcpListener.AcceptTcpClientAsync does not get cancelled
CancellationTokenSource cancel = new(400);

TcpClient JoinedClient = await Server.AcceptTcpClientAsync(cancel.Token);
CancellationTokenSource cancel = new(400);

TcpClient JoinedClient = await Server.AcceptTcpClientAsync(cancel.Token);
so i expect this code to accept any tcp clients and if a 400ms period pass it will cancel but for whatever reason AcceptTcpClientAsync keeps halting my execution! i could probably run my own wait timer and if the timer finishes then i will call TcpListener.Stop() but i can see how that workaround would cause issues for in the future. and one odd thing is when a tcp client successfully connects to the server the function doesnt finish execution oddly
16 replies