Home
Blog
Projects
About

AspNet Overview

Wednesday, 17 April 2024

Project Overview

This was written before I moved over the project to Blazor

This portfolio site was made using an ASP.NET Core Web App, and is being hosted on Azure! I'll go over how I learned more about the asynchronous workflow, the repository design pattern and more all in this post. I'll also go over some problems I had with hosting my website, as well as some future improvements I have in mind.

After 3 attempts, I've managed to get this project to a state where I can release it to the public and be proud of it. This time around everything that was blocking me from understanding how MVC worked wasn't there, everything was clicking in my head and I was able to understand the software I was creating. In earlier attempts, I was new to the .NET world, and over time I've learned about how MVC works in more detail, as well as becoming accustomed to the use of controllers and dependency injection in an ASP.NET Core App. If I had to put a pin on one thing that was preventing me from completing my past attempts, I think it was the concept of DTO's. As simple as it might be for me to explain it now, it really was a pain point for me. After reading up and watching videos talking about ASP.NET MVC, I came upon someone talking about the DTO's in terms of 'request' objects. I think that the distinction between it being a data-transfer object to a request object had an impact on my understanding.

The objective of this project was to build a portfolio for myself where I could post blogs and projects, as well as some tags that I could use to identify my posts. There was no problem with where II originally had my portfolio hosted. I was hosting it on Webflow, where I was using a template, and using its own CMS. To be quite honest, it was also cheaper overall, but I think that the price is worth it to have this project be something I continue to iterate and improve on. I wanted a website where I could create blog posts, projects, and tags. Blogs have a many-to-one relationship with Projects, and as such, Projects have a one-to-many relationship with Blogs. Tags have a many-to-many relationship to both blogs and tags.

I used Visual Studio to code, Azure to host the Web App, the 2 databases (one for my content, and the other for my users), and an Azure KeyVault to store my secrets. I also have incorporated Disqus on all my blogs and project posts so that I can have comments on my site. During this project, I learned about the repository design pattern. This pattern allows me to abstract away the querying of the databases from the controllers to their class. I created an interface for each of the types of content I'd be storing in a database ( I'll talk more about where I can improve this later), which each can perform the CRUD actions. I also learned how easy it is to inject dependencies into my classes. After I created an implementation for each of the repository interfaces, I injected them into the app. From there I was able to do something like  var blogs = blogPostRepository.GetAllAsync(), instead of implementing the crud operation in each of the controllers. I also got to see how easy it is to change implementations if I so choose to without changing the class, but by creating a new one. I have an IImageRepository, of which I currently have 1 implementation, which reaches out to Cloudinary, a site where I host my pictures. If there was ever a time when I wanted to change where I hosted the pictures, I could create a new Repository implementation from that IImageRepositoryinterface. Super cool! Azure was a beast of its own during this project. It was my 2nd time trying to use Azure, this time I was able to create it with a lot more ease because of the integration it has with Visual Studio. I was able to create my app and deploy it all straight from my IDE!

There isn't much on the front side of this portfolio site, but on the backend, I think it looks pretty cool! I have a separate section of the site available to me since I am the admin, where I can CRUD my content. I have filtering and a search bar operable ( I'll get to yours shortly :D )! It's a small thing, but I really like how I managed to get a dynamic list of "Associated Blog Posts" for each of the projects that have blog posts. Projects also have a GitHub repo icon which, again, wasn't something hard to do, but for some reason I really like how it's been shaping up.

This project was the first time I created some tests that would be used for some sort of CI/CD workflow. I took the default GitHub workflow given to me by Azure and created a new section that would run my unit tests to make sure they passed before deploying my app. As of writing this post, I don't have much coverage of my code at all but I'll improve it over time when I make more tests and such.

In the future, I want to convert this to use Blazor, where I can make use of Blazor Components and Blazor Libraries like MudBlazor. I have a little experience with MudBlazor from my past attempt and I'd like to use it again with this site. I also want to change how I create the interfaces for my repositories to be of type T and create implementations of type T. This will allow me to consolidate my interfaces, but keeping my implementations the same.

Thanks for reading through my post, I hope you have a great rest of your day! :D

An unhandled error has occurred. Reload 🗙