﻿<?xml version="1.0" encoding="utf-8"?>
<rss
  version="2.0">
  <channel>
    <title>IT Blog</title>
    <link>https://rasolo.net/blogs/it/feed/</link>
    <description />
    <language>en-us</language>
    <managingEditor>rasmusolofsson@protonmail.com</managingEditor>
    <lastBuildDate>Tue, 02 May 2023 14:21:40 Z</lastBuildDate>
    <item>
      <link>https://rasolo.net/blogs/it/source-tree-vs-gitkraken-vs-fork/</link>
      <category>IT</category>
      <title>Which Git GUI is the best?</title>
      <description>Update 2020-09-09
1. Fork

Has the most features.
Automatic and non-intrusive updates.
Experienced zero bugs so far.

2. Sourcetree

Similar to Fork but less features.
Bugs on every PC i've installed it on.
No automatic updates.

3. GitKraken

Lacking in features and feels too primitive with the free version.

4. Visual Studio Team Explorer
This is a GIT GUI feature in the IDE Visual Studio.

It would be better than GitKraken if it allowed selecting of specific lines to be discarded. Lacking this feature makes it worse.

5. Github Desktop

Impossible to use this at work. Lacking too many features.
</description>
      <pubDate>Sun, 13 Oct 2019 16:09:57 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
    <item>
      <link>https://rasolo.net/blogs/it/csr-private-key-location/</link>
      <category>IT</category>
      <title>How to find the CSR private key generated by DigiCert for Windows</title>
      <description>A private key for the CSR is automatically generated when using Digicert Certificate Utility for Windows and can be found in the Microsoft Management Console underneath Certificates. Click on File -&gt; Add/Remove Snap in and add Certificates. Expand the "Certificate Enrollment Requests" and click on the "Certificates" folder. You can find the certificate here and extract the private key.
 
Extract the private key by right clicking the certificate and choose "All tasks -&gt; Export". Click next, select the "export private key" option and next. Let the defaults stay in the next window and click on next. Choose the password option in the next window and click on next. Choose a file name. By default the file will be saved with a .pfx extension.
Download Open SSL: http://slproweb.com/products/Win32OpenSSL.html
Open command prompt, navigate to C:\OpenSSL-Win32\bin&gt;, and run the following commands:
Set OPENSSL_CONF=c:\openssl-win32\bin\openssl.cfg 
openssl pkcs12 -in filename.pfx -nocerts -out key.pem
openssl rsa -in key.pem -out myserver.key
The private key will be saved as ‘myserver.key’.
 
Carefully protect the private key. Be sure to backup the private key, as there is no means to recover it, should it be lost.
 
Thanks to: https://docs.druva.com/Knowledge_Base/inSync/How_To/Using_Microsoft_IIS_to_generate_CSR_and_Private_Key</description>
      <pubDate>Tue, 02 Jun 2020 15:19:12 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
    <item>
      <link>https://rasolo.net/blogs/it/how-to-do-if-statements-in-razor/</link>
      <category>IT</category>
      <title>How to do if statements in Razor</title>
      <description>Example 1:
&lt;div class="@if(Model.InvertedColor){&lt;text&gt;text-white&lt;/text&gt;} content-meta__published_at mb-3x"&gt;
 
Example 2:
&lt;div class="@(Model.InvertedColor ? "text-white" : string.Empty) content-meta__published_at mb-3x"&gt;</description>
      <pubDate>Wed, 03 Jun 2020 19:26:38 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
    <item>
      <link>https://rasolo.net/blogs/it/delete-user-sql/</link>
      <category>IT</category>
      <title>How to delete an undeleteable user in SQL Server</title>
      <description>I was not able to delete a user in my SQL Server. The error message that was thrown was something like: "Can not alter user dbo". The user had previously had a membership connection to a database.
The solution was to temporarily detach the previous database in order to delete the user from SQL server.

Right click the database
Tasks
Detach
Check the "Drop connections" box
Click Ok
Right click the user under Security -&gt; Logins for SQL Server
Delete the user

 
After that I could restore the database and re-add the user to it.
In order to reattach the database:

Right click "Databases" under SQL Server
Attach
Add
Select the database you had detached
Click ok
</description>
      <pubDate>Fri, 05 Jun 2020 10:23:08 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
    <item>
      <link>https://rasolo.net/blogs/it/sql-database-log-in-error/</link>
      <category>IT</category>
      <title>How to fix logging into SQL database error</title>
      <description>After restoring a database I got an error for the user not being able to log in even though the credentials were correct. The user was using SQL server log in method, so the solution was to enable logging into the database using SQL Server logins and not just the default Windows Authentication method.
Right click the SQL server -&gt; Properties -&gt; Security -&gt; SQL Server and Windows Authentication mode -&gt; Ok.
 
</description>
      <pubDate>Fri, 28 Aug 2020 15:36:26 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
    <item>
      <link>https://rasolo.net/blogs/it/sql-uses-old-database/</link>
      <category>IT</category>
      <title>Fix SQL server using old database on restore</title>
      <description>I was using an old dev database for work and wanted to use the newer database from production. I deleted my old database and restored to a new database based on the one from production, with the same name as the old database. This made it so that the old database kept being used.Solution:
I deleted the database using SQL script "Drop database" instead of deleting it from SSMS by right clicking it and choosing "delete". I also had to right click SQL Server from SSMS and choose Properties -&gt; Advanced -&gt; Enabled Contained Databases -&gt; True (instead of false).
For good measure it might be worth it to also delete the .mdf and .ldf files in this folder (depending on your version in the path):C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATASo if your old databases name is "MyDatabase" you should delete the files "MyDatabase.mdf" and "MyDatabase.ldf".In order to get access to the folder I had to right click it and give myself permission to enter the folder.</description>
      <pubDate>Thu, 23 Jan 2020 16:18:06 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
    <item>
      <link>https://rasolo.net/blogs/it/free-ssl-on-azure/</link>
      <category>IT</category>
      <title>Free SSL/HTTPS on Azure</title>
      <description>Apparently all websites on Azure with &lt;name&gt;.azurewebsites.net gets a free wildcard certificate issued by Microsoft. This means that the website you create will automatically get https, for free and without you doing anything.I have had my website for 6+ months without realizing this. I thought it was a paid feature for basic tier and above but apparently even free tiers gets HTTPS. I tested it out by appending "https://" before my site and lo and behold, https is activated. All I had to do now was to rewrite from HTTP to HTTPS.
My code for rewrite looks like this:
 &lt;rewrite&gt;&lt;rules&gt;&lt;clear /&gt;&lt;rule name="Redirect to https" stopProcessing="true"&gt;&lt;match url=".*" /&gt;&lt;conditions&gt;&lt;add input="{HTTPS}" pattern="off" ignoreCase="true" /&gt;&lt;/conditions&gt;&lt;action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" /&gt;&lt;/rule&gt;&lt;/rules&gt;&lt;/rewrite&gt;
Not only do you get 10 free web apps (permanently?) from Azure but HTTPS as well, automatically! And one year of free SQL database. I pay nothing for my website, web api and database. I almost feel bad for it.</description>
      <pubDate>Thu, 23 Jan 2020 20:44:20 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
    <item>
      <link>https://rasolo.net/blogs/it/azure-uses-old-database/</link>
      <category>IT</category>
      <title>Azure uses old deleted database solution</title>
      <description>I created a new database on Azure based on a .bacpac file from the production environment for a customer project to use in the dev and uat environments. For the dev environment it kept displaying the old database even though it had been deleted and I had changed the connection string to point to the new database. Locally it worked perfectly to connect to the new database. At first I only changed the connection string through FTP and then I realized that the connection string under the configuration section in Azure portal overrides the connection string defined in web.config. Changing the connection string there fixed it for the dev environment. This did not help for the uat environment however.
For the uat environment I updated the connection string in the configuration settings, I also updated the connection string through FTP/Azure live edit but to no success. I even created another new database to see if it works, no help there. Worked perfect locally. Restarting the website did not work. But stopping and starting the site did. Thanks to great coworkers who had experienced this issue before I was able to solve it quicker and could cancel the Microsoft support ticket.
Solution:

Create the new database with a new name that has not been used before (should not be necessary but even locally I have had problems with the old database being used if I delete it and restore a new database with the same name as the old one)
Update the connection string under the configuration settings in your Azure web app in the Azure portal.
Stop and then Start the site in the Azure App Service overview section. (Restarting does not help, you have to Stop and then Start).
</description>
      <pubDate>Fri, 24 Jan 2020 12:39:56 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
    <item>
      <link>https://rasolo.net/blogs/it/import-sql-database-solution/</link>
      <category>IT</category>
      <title>SQL Error importing database solution</title>
      <description>Right click SQL Server from SSMS and choose Properties -&gt; Advanced -&gt; Enabled Contained Databases -&gt; True (instead of false).</description>
      <pubDate>Sat, 25 Jan 2020 12:40:32 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
    <item>
      <link>https://rasolo.net/blogs/it/docker-node-run-error/</link>
      <category>IT</category>
      <title>Docker node volumes error solution</title>
      <description>Sometimes (very often) for a project, when cding into a subfolder of a docker volume I would get this error when trying to run any commands related to npm and node:

path.js:1077path = process.cwd();^ Error: ENOENT: no such file or directory, uv_cwdat Object.resolve (path.js:1077:24)at Function.Module._resolveLookupPaths (internal/modules/cjs/loader.js:534:17)at Function.Module._resolveFilename (internal/modules/cjs/loader.js:629:20)at Function.Module._load (internal/modules/cjs/loader.js:562:25)at Module.require (internal/modules/cjs/loader.js:692:17)at require (internal/modules/cjs/helpers.js:25:18)at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21at Object.&lt;anonymous&gt; (/usr/local/lib/node_modules/npm/bin/npm-cli.js:153:3)at Module._compile (internal/modules/cjs/loader.js:778:30)at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

which was extremely frustrating. Node works perfectly fine when not cding into a subdirectory but as soon as I cd inside them, node stops working. My command would look like this:
docker run --rm -v ${pwd}:/v node:10 bash -c "cd /v/Frontend; yarn dist"

which would throw the error. However, if I ran the command without cding, it would work:
docker run --rm -v ${pwd}:/v node:10 bash -c "cd /v; yarn dist"

 
The solution was to run this command first:

npm cache clean -f

after that it would work perfectly. So the final command would look like this:

npm cache clean -f; cd vol/Frontend; yarn dist

 
 </description>
      <pubDate>Sun, 26 Jan 2020 21:51:32 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
    <item>
      <link>https://rasolo.net/blogs/it/microsoft-teams-login-solution/</link>
      <category>IT</category>
      <title>How to fix Microsoft Teams login issue</title>
      <description>
 
I logged in to Microsoft Teams and kept getting the message "You're not on Teams yet, but you can set it up for your organization." Did not matter if I logged out or restarted the pc.The solution was to uninstall the application, install it again and log out of the application and log in again.</description>
      <pubDate>Thu, 30 Jan 2020 10:32:00 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
    <item>
      <link>https://rasolo.net/blogs/it/how-to-redirect-a-naked-http-domain-to-an-ssl-protected-www/</link>
      <category>IT</category>
      <title>How to redirect a naked http domain to an ssl protected www</title>
      <description>I had just activated the shared hosting plan in Azure in order to try out a custom domain with HTTPS. My hand was forced to use the shared hosting plan since the tier below that allows you to buy a custom domain, but not use HTTPS. This is sneaky in my opinion since a custom domain is pretty useless without HTTPS when all browsers gives a warning and prevents you from entering the site if it lacks a certificate. Anyway.
Azure does not provide you with HTTPS for the naked url (the naked url is the url without www, eg: http://domain.com is naked whereas http://www.domain.com is not). Since users would get a huge warning from browsers and prevent them from entering if they go to my website using the naked url I wanted to redirect from the naked to the "clothed" (www) url. It refused to work.
The solution was to activate ssl on the naked url by using Let's Encrypt. Redirects will only work if the domain has a certificate apparently. I had tried Let's Encrypt for hours before without success until finally discovering that you need the shared or higher hosting plan for Let's Encrypt or any kind of SSL to work. I used the Let's Encrypt site extension https://github.com/sjkp/letsencrypt-siteextension to get it to work. (The letsencrypt-webapp-renewer https://github.com/ohadschn/letsencrypt-webapp-renewer does not work right now 2020-02-09) It worked perfectly the first try and only the naked domain got the Let's Encrypt certificate, the "clothed" domain was left alone and keeps it's Azure certificate.
Below are redirects that works to redirect from both HTTP and HTTPS to www, with the lower rule being for HTTPS. Replace domain.com with your domain. 

&lt;rule name="Redirect domain.com to www.domain.com HTTP" patternSyntax="ECMAScript" stopProcessing="true"&gt;
  &lt;match url=".*" /&gt;
  &lt;conditions&gt;
    &lt;add input="{HTTP_HOST}" pattern="^domain.com$" /&gt;
    &lt;add input="{HTTPS}" pattern="off" /&gt;
  &lt;/conditions&gt;
  &lt;action type="Redirect" url="http://www.domain.com/{R:0}" redirectType="Permanent" appendQueryString="true"/&gt;
&lt;/rule&gt;
&lt;rule name="Redirect domain.com to www.domain.com HTTPS" patternSyntax="ECMAScript" stopProcessing="true"&gt;
  &lt;match url=".*" /&gt;
  &lt;conditions&gt;
    &lt;add input="{HTTP_HOST}" pattern="^domain.com$" /&gt;
    &lt;add input="{HTTPS}" pattern="on" /&gt;
  &lt;/conditions&gt;
  &lt;action type="Redirect" url="https://www.domain.com/{R:0}" redirectType="Permanent" appendQueryString="true"/&gt;
&lt;/rule&gt;

 
I will see if I will stick with the shared plan since the estimated cost is almost 50$ a month. If the bill lands there then I don't see it as worth it just to have a custom domain with HTTPS. I would rather stick with .azurewebsites.net then.</description>
      <pubDate>Sat, 08 Feb 2020 23:04:43 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
    <item>
      <link>https://rasolo.net/blogs/it/how-to-whitelist-cloudflare-ips/</link>
      <category>IT</category>
      <title>How to whitelist Cloudflare IPs</title>
      <description>First go to this url to find out the ip ranges Cloudflare has: https://www.cloudflare.com/ips/. The ips will look something like this:
173.245.48.0/20
I did not know what the /20 meant so I simply removed it when whitelisting and of course it did not work. For all the ips listed you have to find out the subnet mask which you can do with the CIDR which is the /20 in this case. You can use this subnet calculator site in order to find out the subnet mask: https://mxtoolbox.com/subnetcalculator.aspx. Input the ip address and select the CIDR (the number after the forward slash) in order to retrieve the subnet mask.
Since I use dotnet with web.config and ipsecurity, the final whitelisting result will look like this:
&lt;add allowed="true" ipAddress="173.245.48.0" subnetMask="255.255.240.0" /&gt;&lt;add allowed="true" ipAddress="103.21.244.0" subnetMask="255.255.252.0" /&gt;&lt;add allowed="true" ipAddress="103.22.200.0" subnetMask="255.255.252.0" /&gt;&lt;add allowed="true" ipAddress="103.31.4.0" subnetMask="255.255.252.0" /&gt;&lt;add allowed="true" ipAddress="141.101.64.0" subnetMask="255.255.192.0" /&gt;&lt;add allowed="true" ipAddress="108.162.192.0" subnetMask="255.255.192.0" /&gt;&lt;add allowed="true" ipAddress="190.93.240.0" subnetMask="255.255.240.0" /&gt;&lt;add allowed="true" ipAddress="188.114.96.0" subnetMask="255.255.240.0" /&gt;&lt;add allowed="true" ipAddress="197.234.240.0" subnetMask="255.255.252.0" /&gt;&lt;add allowed="true" ipAddress="198.41.128.0" subnetMask="255.255.128.0" /&gt;&lt;add allowed="true" ipAddress="162.158.0.0" subnetMask="255.254.0.0" /&gt;&lt;add allowed="true" ipAddress="104.16.0.0" subnetMask="255.240.0.0" /&gt;&lt;add allowed="true" ipAddress="172.64.0.0" subnetMask="255.248.0.0" /&gt;&lt;add allowed="true" ipAddress="131.0.72.0" subnetMask="255.255.252.0" /&gt;
the example above will probably get outdated eventually as Cloudflare updates their ip addresses. But now you know how to retrieve the new subnet masks.
In my case I wanted to whitelist Cloudflare in order to gain access to this sites back office editor/admin section. I also had to whitelist my own ips such as my home network in order to gain access.
My final whitelisting looks like this:
&lt;location path="umbraco"&gt;&lt;system.webServer&gt;&lt;security&gt;&lt;ipSecurity enableProxyMode="true" allowUnlisted="false" denyAction="Unauthorized"&gt;&lt;add allowed="true" ipAddress="{privateIp}" /&gt;&lt;add allowed="true" ipAddress="{privateIp}" /&gt;&lt;add allowed="true" ipAddress="{privateIp}" /&gt;&lt;!-- Cloudflare whitelist--&gt;&lt;add allowed="true" ipAddress="173.245.48.0" subnetMask="255.255.240.0" /&gt;&lt;add allowed="true" ipAddress="103.21.244.0" subnetMask="255.255.252.0" /&gt;&lt;add allowed="true" ipAddress="103.22.200.0" subnetMask="255.255.252.0" /&gt;&lt;add allowed="true" ipAddress="103.31.4.0" subnetMask="255.255.252.0" /&gt;&lt;add allowed="true" ipAddress="141.101.64.0" subnetMask="255.255.192.0" /&gt;&lt;add allowed="true" ipAddress="108.162.192.0" subnetMask="255.255.192.0" /&gt;&lt;add allowed="true" ipAddress="190.93.240.0" subnetMask="255.255.240.0" /&gt;&lt;add allowed="true" ipAddress="188.114.96.0" subnetMask="255.255.240.0" /&gt;&lt;add allowed="true" ipAddress="197.234.240.0" subnetMask="255.255.252.0" /&gt;&lt;add allowed="true" ipAddress="198.41.128.0" subnetMask="255.255.128.0" /&gt;&lt;add allowed="true" ipAddress="162.158.0.0" subnetMask="255.254.0.0" /&gt;&lt;add allowed="true" ipAddress="104.16.0.0" subnetMask="255.240.0.0" /&gt;&lt;add allowed="true" ipAddress="172.64.0.0" subnetMask="255.248.0.0" /&gt;&lt;add allowed="true" ipAddress="131.0.72.0" subnetMask="255.255.252.0" /&gt;&lt;/ipSecurity&gt;&lt;/security&gt;&lt;/system.webServer&gt;&lt;/location&gt;
 
So in dotnet you also have to enable proxy mode in the ip security element like so:
&lt;ipSecurity enableProxyMode="true" ..</description>
      <pubDate>Fri, 21 Feb 2020 20:00:06 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
    <item>
      <link>https://rasolo.net/blogs/it/brother-not-printing-pdf/</link>
      <category>IT</category>
      <title>How to fix Brother printer not printing PDF files</title>
      <description>I bought a Brother printer (HL-L2350DW) and it refused to print PDF files. An error message appeared in Windows saying something like "Brother HL-L2350DW could not print the PDF file" when attempting to print. When I installed driver software i chose to only install the "Printer driver" thinking that would be enough so that I wont have to install unnecessary bloatware, but I was wrong.
After installing the recommended "Full driver &amp; software package" https://support.brother.com/g/b/downloadlist.aspx?c=us_ot&amp;lang=en&amp;prod=hll2350dw_us_eu_as&amp;os=10013 I was able to print PDF files. There does not seem to be any bloatware in that installation though so it's alright.</description>
      <pubDate>Mon, 04 May 2020 15:12:39 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
    <item>
      <link>https://rasolo.net/blogs/it/custom-vs-field-name/</link>
      <category>IT</category>
      <title>Custom auto generated field name in Visual Studio</title>
      <description>Here is how to change the default Visual Studio auto generated field naming convention from PascalCase and the .this keyword to the more standard underscore and camelCase.
So this default code will change:
	private readonly IPublishedContentMapper AnaxiMapper;

		public BlogPostPageController(IPublishedContentMapper anaxiMapper)
		{
			this.AnaxiMapper = anaxiMapper;
		}
Into this:
	private readonly IPublishedContentMapper _anaxiMapper;

		public BlogPostPageController(IPublishedContentMapper anaxiMapper)
		{
			_anaxiMapper = anaxiMapper;
		}
Go to Tools -&gt; Text Editor -&gt; C# -&gt; Code style -&gt; Naming

 
Click on "Manage naming styles".

Click on the plus sign at the bottom left to add a new naming style.

 
Fill in the name of the naming style at the top, e.g _fields.
Fill in the prefix at "Required prefix", in my example an underscore: _. An example on how it will look will appear in the bottom text box.
</description>
      <pubDate>Sat, 11 Mar 2023 18:26:09 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
    <item>
      <link>https://rasolo.net/blogs/it/resizing-windows-11-applications/</link>
      <category>IT</category>
      <title>Get resizing of Windows 11 applications working again</title>
      <description>Sometimes Windows 11 application resizing feature stops working for me; the application windows when resizing turns into a gray color and the windows does not move or resize as the size of the window is changed.This is solved by typing "performance" into the search window and opening the "Adjus the appearance and performance of Windows" application:

Make sure the checkbox "Show window contents while dragging" is selected. If it already is selected, unselect it and click apply then select it again so that the checkbox is checked and click apply. This should restore the resizing feature.
</description>
      <pubDate>Tue, 02 May 2023 14:10:35 Z</pubDate>
      <author>rasmusolofsson@protonmail.com</author>
    </item>
  </channel>
</rss>