Attach to Process

Thoughts and Notes on Software Development

In my last DevLog, I mentioned that I took down apps.dinobansigan.com, and with it, the Write.as Archive Page Generator. I said I was letting it go. Well, that lasted about two months.

So, I went to update one of my other blogs recently, and realized the archive page on it was way out of date. The tool I used to update it was gone. Turns out I still needed it after all.

Why it can't just be a website

The old version was a Blazor WASM app. Since it ran in the browser, it couldn't call the Write.as API directly because of CORS. My workaround was to write my own API for the Blazor app to call, running as an Azure App Service. That API ran on free Azure credits that I've since lost access to.

I didn't want to host something again, since that means paying for it. And I didn't want to fight CORS again either. So this time around, the answer was an app that runs locally on my own machine. CORS only applies to browsers, so a regular app can call the Write.as API just fine.

Rebuilding it with Claude Code

I rebuilt this one with Claude Code. I treated it like pairing with another developer. Claude wrote most of the code, and I reviewed every change before it went in. Good news was, I still had the source code for both the old Blazor app and the API on my machine, so we had something to work off of. We ended up with a simple .NET console app. You run it with your blog's alias, and it spits out the HTML for your archive page. Same output as before, same CSS classes, so if you customized the look of your archive page, it should still work.

It still uses my WriteAs.NET library to talk to the Write.as API. But we swapped out CommonMark.NET and HtmlAgilityPack for Markdig, which turns the Markdown of untitled posts into plain text in a single line of code. CommonMark.NET hasn't been updated in years, so it was time anyway. Going through my old code also turned up a few bugs, like the app crashing on short untitled posts. Oops.

From reading through the old code to having a working app up on GitHub, the whole thing took one afternoon.

Rate limiting

The biggest surprise was that Write.as now heavily rate limits calls to its API. And because of how I wrote WriteAs.NET, a rate limited call just comes back empty instead of throwing an error. So the first test run fetched 20 out of 55 posts, and would have happily given me an incomplete archive page without me knowing.

The fix was to slow things down. The app now waits 10 seconds between each page of posts, retries if it still gets rate limited, and checks the number of posts it got against what the blog says it has. It's slow, but it gets all of them. Funny enough, that's an improvement over the old version, which used to time out on blogs with a lot of posts. An API key would probably help with the rate limiting, but I don't have one set up right now.

There was also a bug in the new version where some emojis in post titles showed up as code instead of the actual emoji. That one got fixed real quick.

It's on GitHub

Back in 2022, I said I'd share the source code for the WPF version of this tool if there was enough interest. This time around, I'm just putting it out there: writeas-archive-generator. It's a console app, so no pretty UI, but it does the job. You'll need the .NET 10 SDK to run it, and the README has all the details.

Eventually, I want to build a Windows desktop app with a UI for it. But for now, this works, and my archive page is up to date again. Thanks for reading, and I'll catch you in the next DevLog.

Tags: #DevLog #ClaudeCode #DotNet #CSharp #WriteAs #WriteAsNet

Discuss... or leave a comment below.

I've had a personal Claude Pro subscription for a few months now. I've used it to build a few apps that my kids and I use at home. Most recently, I rebuilt my personal homepage with the help of Claude Code.

Choosing a tech stack

Part of my discussion with Claude was what tech stack to build the new site on. I considered React, ASP.NET, or even a popular static site generator like Eleventy. But at the end of the day, those all felt like overkill for a static site with at most 2-3 pages. I decided to just have Claude build it with plain HTML and CSS. Any future updates I can handle myself by editing those files directly, and with continuous deployment from GitHub to Netlify, shipping a new build is quick and easy.

That continuous deployment pipeline turned out to be one of the real benefits of using Claude to help build websites. It knows GitHub, and it knows Netlify. I had no idea how to set up a pipeline that deploys automatically from GitHub to Netlify, and researching it myself probably would've taken a few hours. With Claude, I had step-by-step instructions and a working pipeline in under 10 minutes.

Read more...

So, for awhile now, the Write.as Archive Page Generator on my hobby site wasn't working anymore. For some reason, calls to the Write.as api just started failing. The error I was getting back was “The response ended prematurely.”

Took me awhile, but I finally found a fix for the error. Turns out, I now need to add a “user-agent” default header value to my requests, to allow the api call to go through. This seems to be an issue affecting Web APIs written using C#/.NET starting June 2024. Credit goes to this answer from StackOverflow.

Tags: #DevLog#ASPNETCore #WebDevelopment #WriteAs

Discuss... or leave a comment below.

It's been awhile since I wrote on this blog. I'm currently working on a possible rebuild of my landing page found at dinobansigan.com. That website is a static website generated using Wyam. I'm thinking of rebuilding it using ASP.NET Razor Pages.

I thought about rebuilding it using ReactJS. But for a mostly read-only website, using React seems overkill. Same goes for using ASP.NET Core MVC; it is overkill for such a simple website. Thought about using Blazor, but I do not need this website to be an SPA. So, ASP.NET Razor Pages seems like the perfect choice for what I want to do.

I only started working on this like 30 minutes ago. Here's what I have so far.

After I'm satisfied with the content on the pages, I'll move on to modifying the look/theme of the website. Then will need to figure out where to host it.

Part of the reason I stuck with a static website build, is because I can host it for free on Netlify. However, I've been wanting to see what it takes to host an ASP.NET website outside of Azure. Now is my chance to learn how to make that work.

Tags: #DevLog#ASPNETCore #WebDevelopment

Discuss... or leave a comment below.

Was getting this error from Visual Studio 2022 while debugging a unit test. Moq error in Visual Studio 2022

The solution for me was to uncheck the “Call string-conversion function on objects in variables windows” checkbox. Solution for Moq error in Visual Studio 2022

Tags: #Debugging #Moq #Tests #VisualStudio

Discuss... or leave a comment below.

Fire and forget template for C#/.NET to run something that you don't need to wait on and don't care about the results.

Task.Run(() =>
{
	//code goes here
});

In ReactJS, if ESLint says you cannot use inline arrow functions to pass in props in JSX, a solution is to wrap them with the useCallback hook.

Reference: https://stackoverflow.com/a/36677798/5041911


Modals — can be used to add dialog or popup info boxes on your ReactJS app.


So using this library actually helped me solve my Azure Application Insights logging issue. The issue being, since I had a dateOfBirth object in my formData object, app insights would save it as an object, as opposed to something like dateOfBirth: 2024-04-16. The solution was to flatten the formData object so it will get logged properly in Azure App Insights.


Rendering the HTML string in React — short tutorial on how to render an HTML string in ReactJS/Gatsby.


Series: #DevNotes Tags: #CSharp #DotNet #Template #ReactJS #Azure #ApplicationInsights #Gatsby

Discuss... or leave a comment below.

There was a bug on my Write.as Archive Page Generator web app. Instead of creating URLs with the correct alias in there, for instance https://write.as/dino/blog-post-title, it was hard-coding the word alias, like https://write.as/alias/blog-post-title.

It was an easy fix, though it wasn't the web app that was broken, but the API that it was calling. I mentioned in a previous post, that I was working on an API to power my Blazor WASM apps. The API is functional, it's out there on the internet, running as an Azure App Service. And it's the one with the bug that I just fixed a few hours ago.

So, the Write.as Archive Page Generator should be working correctly now. You no longer need to do a “search and replace” on the output to correct the URLs.

Tags: #Blazor #WriteAs

Discuss... or leave a comment below.

To cause Azure to keep sending emails repeatedly for your Heath Check alerts, you need to uncheck the checkbox that says “Automatically Resolve Alerts”.


If you want to see what kind of error Axios throws, it is better to use console.log(error.toJSON()) than console.log(error). That's because the former option will list out all the properties from the error variable, while the latter option will only list out the error message itself.


Instead of adding todo comments, track it as a task so it doesn't get lost.

Source: TODO: Post an Article


Looking for a new way to do end-to-end testing on modern web apps? Check out Playwright. The tests are pretty easy to follow because it's basically a set of instructions written in code. So as you might have guessed, it's catered more to developers than non-technical folks.


I am going through the Pro ASP.NET Core 6 book. After trying to run the command libman install bootstrap@5.1.3 -d wwwroot/lib/bootstrap from page 72 (Chapter 4) of the book, I started getting the error listed below:

[LIB002]: The "bootstrap@5.1.3" library could not be resolved by the "cdnjs" provider

Turns out it was an issue with the library manager package that was installed. The fix is to install a newer one. More info can be found here:

https://github.com/Apress/pro-asp.net-core-6/blob/main/errata.md


Was looking for a way to add a list of objects to the appsettings.json file, then retrieve that list and turn them into something I can check against in a controller class. This answer works wonderfully.


React Hook Form — seems like a cool alternative form handler for React.


SQL to MongoDB Mapping Chart — good reference on how to write MongoDB queries based on expected SQL Server queries.


Reasons to blog if you're a software developer:

  • It helps you write better emails at work.
  • It helps you write better user stories and acceptance criteria.
  • It helps you communicate your ideas better.

If you're noticing a pattern there, it's all about being a better communicator. And you would want that, because that also helps you advance in your career.


Series: #DevNotes Tags: #Axios #ASPNetCore #Azure #Blogging #JavaScript #MongoDB #Playwright #React #SqlServer #Tests

Discuss... or leave a comment below.

My Write.as Archive Page Generator is back up and running. I've already updated the Archive pages for my other blogs. It seems to be working fine. Please give it a try and let me know if you run into any issues with it.

I did notice, during my testing, that it can fail on blogs with a huge number of posts. That's mainly because the API call times out at like the 1.7 minute mark. I'll see if I can fix that in the future. But for now, just getting the archive page generator working is a win. So I'll call it a day.

Tags: #Blazor #WriteAs

Discuss... or leave a comment below.

Version 1.2.1 of WriteAs.Net has been released.

This very minor update adds an interface for the WriteAsClient class, which opens it up for use with dependency injection in ASP.NET Core. This allows you to create a single WriteAsClient instance and re-use it when needed, making the caching additions from Version 1.2.0 much more useful.

This also frees me up to make better use of it in the API I'm working on.

You can install it via nuget: Install-Package WriteAs.NET -Version 1.2.1

Or via the .NET Core command line interface: dotnet add package WriteAs.NET --version 1.2.1

If you find any bugs or issues with it, please let me know. Thanks and y'all have a good night.

Tags: #DotNet #WriteAs #WriteAsNet

Discuss... or leave a comment below.

Enter your email to subscribe to updates.