Skip to main content

C# Random Password Generator for ASP.NET Core & ASP.NET MVC Identity Framework

Yesterday I had to create a C# method that creates a random generated password in C#. Before committing into it I spent some minutes surfing the web, trying to find something I could use. I stumbled upon this 2006 post from Mads Kristensen, which is a guy I seriously love for all the great work he did with some incredibly useful Visual Studio extensions such as Web Essentials, Web Compiler, ASP.NET Core Web Templates – and much more.

However, the function I found in that post didn’t help me much, because it had no way to ensure any strong-password requisite other than the minimum required length: more specifically, I need to generate password with at least one uppercase & lowercase letter, digit and non-alphanumeric character – and also a certain amount of unique characters. The random password generated against the Mads function could have them or not, depending on the randomness: that simply won’t do in my scenario, since I had to deal with the UserManager.CreateUserAsync(username, password)  method of the Microsoft.AspNetCore.Identity  namespace, which utterly crashes whenever the password isn’t strong enough.

Read More

Install & Enable AMP Auto Ads by AdSense Labs in Worpdress – How To

If you’re a Google AdSense user you will probably know about AdSense Lab, the incubator hosting those brand-new Ad-based features that aren’t yet ready to be rolled out to all AdSense publishers. The new deal these weeks is called AMP Auto Ads, a new family of advertising units that will be placed automatically within the AMP pages of our website/blog.

In the unlikely event you dont’ know what an AMP page is or if you never heard about the AMP Project, we strongly suggest to fill this huge SEO & accessibility gap by taking a look at the AMP Project’s official page.

The AMP Auto Ads feature is currently in beta and thus accessible only for those who are explicitly invited via e-mail from AdSense Lab. For additional info, read this official guide from Google AdSense. However, since you are here, there’s an high chance you already know everything about AMP Auto Ads and you’re looking for further info about how to properly implement them on your WordPress website or blog.

Read More

WordPress – How to perform Search and Replace on whole Database (post, pages, wp_options) using WP plugins or MySQL tools

Those who are frequently working with Worpress often find themselves operating mass-replace tasks throughout the whole WP Database. Such situation most likely arises in the following scenarios:

  • WebSite URL change (from  www.url-a.com to www.url-b.com), meaning we have to replace the old one in all of our posts/pages.
  • Invalid character issues (mostly due to charset)
  • Having to rename one or more keywords, tags, categories or more (for standard URL & links consistency).
  • Presence of a typo within multiple posts, which you would like to fix without performing thousands of edits.

When we need something like that, we can choose between two possible routes: going for a WordPress plugin to handle such issue in a managed way or work at database level with the help of some free and/or open MySQL management tools.

Read More

WordPress – How to retrieve all posts from one or more given categories with a SQL query

Today a client asked me to remove all the posts from a given category to the auto-generated XML Sitemap of his WordPress blog and also redirect these posts to a new website (same slug, different host): here’s a quick report of how I managed to do that, hoping that it would also help other System Administration that will be given these same tasks.

Read More

RunningLow – A free PowerShell script to check for low disk space and send e-mail to System Administrators

Today I would like to share with our readers RunningLow, a simple yet effective PowerShell script I coded a while ago to get to know when one of my servers is running low of disk space.

Whoever works with physical and/or virtualized Windows Servers is well aware of the importance of keeping this constantly under control: as soon as a server runs out of disk space it will be unable to fullfill a number of tasks, such as: create temporary files, store data on a database, performing system maintenance / backup / updates, create or update web sessions – assuming they are handled through I/O – and so on. Things can be even worse for those servers who host DBMS services such as MySQL and MS-SQL, as the sudden I/O unavailability could cause non-trivial damages to indexes, filesystem-based tables and data integrity.

The main purpose of RunningLow is to prevent all that: it will check one or more local and/or network drives to see if their available free space went under a certain quota, and send a customizable alert to one or more e-mail addresses if that’s the case. I know, there are A LOT of admin suites and maintenance software that could be easily configured to the same thing: even Piriform’s CCleaner PRO does that! However, if you don’t have the money, the time or the amount of system resources required to install these apps, you might find out that this lightweight alternative could be worth a shot.

Read More

Close