Building a beginner-friendly C# application

Learn how to build a beginner-friendly sticky note applicationg using C# and deploy it on Codesphere.

November 21, 2023 2 Min Read
Building a beginner-friendly C# application
Building a beginner-friendly C# application

Hafsa Jabeen

Technical Marketing Engineer

C# was developed by Microsoft and released in the early 2000s as part of the company's .NET initiative. It was designed with a focus on simplicity, type safety, and object-oriented principles. Since then, it has become a popular language used mainly to develop Windows and web applications using ASP.NET. I wanted to show you how easy it is to run a C# application on Codesphere. In this tutorial, I will walk you through the step-by-step process of doing so. 

Setting up the web project

Since we are using Blazor web assembly, we first initialize our web project by the following commands:

dotnet new blazor -o NotesApp
cd BlazorApp

Now we add code to the Home.razor file that represents the default home page of your web application. This file contains the markup and logic associated with the main content that users see when they navigate to the home or root URL of your application.

@page "/"
@rendermode InteractiveServer
@using StickyNotes.Components.Components


<button @onclick="AddNote">Add Note</button>
@foreach (var note in notes)
    <Note OnDelete="() => DeleteNote(note)" />

@code {
    private List<NoteModel> notes = new List<NoteModel>();

    private void AddNote()
        notes.Add(new NoteModel());

    private void DeleteNote(NoteModel noteToDelete)

    private class NoteModel { }

Then we add this code to  Note.razor file which provides a user interface for creating and deleting notes.

@code {
    private string noteContent;

<div class="note-container">
    <textarea @bind="noteContent" placeholder="Write your note here..."></textarea>
    <button @onclick="DeleteNote">Delete Note</button>

@code {
    // You can define an EventCallback if you want to notify a parent component
    public EventCallback OnDelete { get; set; }

    private void DeleteNote()
        // Logic to delete the note
        // If this component is part of a collection, you might want to call OnDelete to notify the parent to remove it

If you like you can find the source code of this project here.

Running the project in Codesphere

To get this project running on Codesphere, you can create an empty working space and import the code from GitHub.

Then you would need to set the dotnet environment and run these commands:

Now we download the dotnet installer for Linux using wget.

wget -O

Next, we assign it the roles that are necessary to run the application.

chmod +x ./

Now add this command to install dotnet.

./ --version latest --install-dir /home/user/app/.dotnet --no-path

The next step is to change the default port from "5000" to "3000" in /Properties/launchSettings.json

  "applicationUrl": "",

Now we use the run command 

/home/user/app/.dotnet/dotnet watch

This will launch the web app.

Alternatively, you can find a preconfigured version of this application in our templates. You can create a workspace and from the drop-down choose this template. You will have all these commands in the CI pipeline.

To understand how you can run a CI pipeline head over to Creating an Angular Template for Codesphere.

I hope you found this article useful, stay tuned for more.

About the Author

Building a beginner-friendly C# application

Hafsa Jabeen

Technical Marketing Engineer

Physics grad turned SEO content writer/marketer, now pursuing computer science.
Converging science, marketing, and tech for innovative experimentation and growth.

More Posts