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

Close