Iron
Iron
CC#
Created by Iron on 2/1/2024 in #help
Should i use C# for this idea??
Hello, i am experienced with PHP,HTML,CSS,Javascript and C# .NET I prob shine the most in C#, but for me honestly the languages are very similar. Anyways, i want to create a web app, this webpage/webapp will have a login system, a subscription system( a charge monthly to use the web app ). So this sytem needs to be able to login, and also store certain items that the user has created, it also has to be able to do some work automatically ( which means server needs to do it at certain times per day ) , the user needs to be able to see what has been done etc and what time. All this will prob be stored in a database, along with the user. Now i need your opinion, yes i do know .NET more as thats the first language i used. But im also very familiar with PHP and Javascript and i feel this could be done there to? Or should i do a web app in c#? What is the positive/negative sides of using C# web apps? Such as Blazor.
13 replies
CC#
Created by Iron on 10/24/2023 in #help
❔ Avoid "Authorizing..." in Blazor Page (Identity)
I am trying to avoid the loading text "Authorizing..." when going to my index.razor page. I have added
`@attribute [AllowAnonymous]
`@attribute [AllowAnonymous]
` to the top of the page but does not seem to solve it. I am able to change the text of the "Authorizing..." in the CascadingAuthenticationView in app.razor but i need to get rid of it on some of my pages because sometimes it takes time to load. Any tips?
7 replies
CC#
Created by Iron on 9/27/2023 in #help
❔ Best way to store ENV Variable in IIS Hosted Blazor?
Hey so i am trying to add a env variable, a sort of API key, in IIS, i know i need to use configuration manager, but i cannot see one in IIS when i am connected to my hosting provider. Anyone know of any other ways i can add env variables on a published app? Or some other ways to store some keys, its a blazor wasm asp net hosted app.
3 replies
CC#
Created by Iron on 9/14/2023 in #help
Role based Authorize Blazor Server + Client
I am stuck trying to use the @attribute [Authorize(Roles = "Admin")] in my blazor component on client side. I started by adding “ .AddRoles<IdentityRole>() “ in program.cs “ public class RoleConfiguration : IEntityTypeConfiguration<IdentityRole> { public void Configure(EntityTypeBuilder<IdentityRole> builder) { builder.HasData( new IdentityRole { Name = "Visitor", NormalizedName = "VISITOR" }, new IdentityRole { Name = "Admin", NormalizedName = "ADMIN" } ); } } “ I made the above class to create the roles Then i added a override in my ApplicationDbContext “ protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.ApplyConfiguration(new RoleConfiguration()); } “ then i ran “ INSERT INTO AspNetUserRoles VALUES ('UserId','Administrator RoleId') “ With the ids that i get from my tables, however, the [Authorize(Roles = "Admin)] on a page still tells me i dont have permissions to view this page. Any tips?
23 replies
CC#
Created by Iron on 9/11/2023 in #help
❔ Assignment: TCPListener that recieves and returns to tcpClient
Hey. I do know how the tcpListener and tcpClient class works in c#, however im stuck on this assignment, the teacher supplied us with a .exe client that sends a string to the server when i click a button, then the server should return another string to the client, i am successfully able to recieve and return the message back to client but in the client, the messagebox that shows the return msg keeps looping, i have tried alot, it just keeps reopening infinte loop and showing blank after the first msg, and i have to close the client using task manager. And i dont dare to ask my teacher if this is a issue with the client and i am not even sure it is Here is my mainForm code: tcpServer server = new tcpServer(); private async void mainForm_Load(object sender, EventArgs e) { labelStatus.Text = "Status: Inväntar data..."; await server.ListenAsync(); } and here is the tcpServer.cs class: public class tcpServer { // We create our datatypes private int portAdress { get; set;} private TcpListener Host { get; set; } public tcpServer() { // Constructor portAdress = 12345; Host = new TcpListener(IPAddress.Any, portAdress); Host.Start(); } public async Task<string> ListenAsync() { using (TcpClient client = await Host.AcceptTcpClientAsync()) { using (NetworkStream stream = client.GetStream()) { //Used to send and receive messages byte[] msg = new byte[1024]; await stream.ReadAsync(msg, 0, msg.Length); return Encoding.Unicode.GetString(msg); } } } } Note that the class above i am just reading the stream to test and it still loops the messagebox. Any help appriciated
24 replies