Skip to content

X Posts

Hide JSON properties in the result set if not set or null, using .net core 3.1 and Newtonsoft

Need to hide properties in your JSON result for a .net core API. Add the following line in your Startup.cs file. Just like below.

opts.SerializerSettings.NullValueHandling = NullValueHandling.Ignore

services.AddMvc(options =>
                {
                    options.InputFormatters.RemoveType<Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter>();
		    options.OutputFormatters.RemoveType<Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonOutputFormatter>();
                })
                .AddNewtonsoftJson(opts =>
               {
                    opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                    opts.SerializerSettings.Converters.Add(new StringEnumConverter(new CamelCaseNamingStrategy()));
                    opts.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
                })
                .AddXmlSerializerFormatters();

You already voted!
Leave a Comment

HTTP Error 500.35 – ANCM Multiple In-Process Applications in same Process (using IIS Express)

I got this error today and was causing me a headache. I stopped all apps running in IIS Express, tried switching releases, etc. But seems like this is a bug in Visual Studio 2019.

Stop your application, close the solution, delete the .vs folder in the solution, open it back up and it should work.

https://stackoverflow.com/questions/58246822/http-error-500-35-ancm-multiple-in-process-applications-in-same-process-asp-ne

You already voted!
Leave a Comment

.net core – launchSettings.json and gitignore

If your working with other developers this file should not be ignored within your .gitignore file. Its useful for environmental and other settings.

I’m not sure why the template I downloaded had it ignored. Seems like its been an issue for a while and has been corrected a few times.

https://stackoverflow.com/questions/47377058/should-i-ignore-launchsettings-json-file-from-being-committed-in-git

https://github.com/github/VisualStudio/issues/1405

You already voted!
Leave a Comment

Adding Unraid Mount Share via Tag to FSTAB

Create a share on the VM machine itself in Unraid.

Let’s assume your mount tag is “test”.

Make sure you create your mount folder within the VM. In our case its “/whatever”. Modify your /etc/fstab file like this to mount the share. Then reboot.

test        /whatever            9p         trans=virtio,version=9p2000.L,_netdev,rw 0 0

You already voted!
Leave a Comment

Network stopped working in Ubuntu 18.04

I had a Ubuntu VM that lost its ability to get an IP. I have no idea why but I finally found the issue and it seems that the interface name changed.

Maybe its a bug : https://bugs.launchpad.net/ubuntu/+source/netplan.io/+bug/1881832

So I found out that the network interface that was trying to do DHCP did not exist. You’ll find this in /etc/netplan/50-cloud-init.yaml . For some reason, it showed that my interface was enp1s0 but it wasn’t, it was enp3s0. So I modified the file and rebooted the server. Everything is fine now.

You already voted!
Leave a Comment

UnRaid Expanding qcow2 drive, Windows 10

To expand your drive size in UnRaid.

  • Go to VMs
  • Click on the name of the VM you want to expand
  • A new bar will appear, disk devices. Click on the capacity.
  • Set a new size and hit enter.
  • Start the machine, log in, etc.
  • Go to administrative tools, computer management, storage, disk management
  • Right click “disk management” and hit refresh
  • You should now see the additional space
  • Expand your disk
  • Done
You already voted!
Leave a Comment

WordPress Errors

Had the following WordPress errors on a website I was working on. I had migrated from one server to another.

  • Cookie nonce is invalid
  • 404 errors for wp-json/wp/v2/posts

I finally tried this trick, adding index.php, to test the URL giving the 404 and it worked http://localhost/myproject/index.php/wp-json/wp/v2/posts.

I switched the Settings -> Permalinks from post name to plain and that worked as well. I put it back and the errors returned.

It ended up being that somehow during migration the .htaccess file was not copied over and was not set up on the new server. Once I copied the .htaccess file from the old to the new server it worked.

Here is a copy of what my .htaccess file looked like at that time.

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


# END WordPress
You already voted!
Leave a Comment

Let’s Encrypt with win-acme (exporting certificate IIS)

Using https://www.win-acme.com for SSL.

To make a certificate exportable in Windows make sure that you modify the “settings.json” that is included with win-acme. Change “PrivateKeyExportable”: false to “PrivateKeyExportable”: true .

If you already created the certificate you might need to delete it then reboot the machine to keep it from giving you a cached version of the SSL certificate.

You already voted!
Leave a Comment

Clear Chrome DNS

For the most part I use chrome and every time I do a modification to my hosts file I don’t want to close the browser because it caches DNS. This seems to work to clear cache chrome://net-internals/#dns

You already voted!
Leave a Comment

Visual Studio 2019 and Sitecore (Troubleshooting) error MSB4036: The “GetReferenceNearestTargetFrameworkTask” task was not found

I have a Sitecore solution built for 2017 but just recently got a fresh computer with only Visual Studio 2019 on it. So I’ve been running through some problems.

This was the error I was getting while running gulp to build the solution. I had installed the VS 2017 build tools earlier. Looks like you need to install the NuGet items as well.

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\amd64\Microsoft.Common.CurrentVersion.targets(1657,5): error MSB4036: The “GetReferenceNearestTargetFrameworkTask” task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is “public” and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the “C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\amd64” directory

You already voted!
Leave a Comment

Disable and Enable SQL Jobs

Quick to disable and enable all SQL jobs on your server

USE MSDB

-- DISABLE ALL SQL JOBS
UPDATE dbo.sysjobs
SET Enabled = 0
WHERE Enabled = 1

-- ENABLE ALL SQL JOBS
UPDATE dbo.sysjobs
SET Enabled = 1
WHERE Enabled = 0

You already voted!
Leave a Comment

KUDU fix “…only displays up to 300 items. This limit can be overridden…”

“Note: by default, it only displays up to 300 items. This limit can be overridden by adding a ‘maxViewItems’ key and value to your browser’s localStorage.”

To fix the issues above and assuming your still at the KUDU interface.

  1. Open developer tools (F12)
  2. Go to console, run window.localStorage[‘maxViewItems’] = 500
You already voted!
Leave a Comment

Duplicati on Ubuntu 16.04 – Headless

Install Mono
https://www.mono-project.com/download/stable/#download-lin-ubuntu

sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
sudo apt install apt-transport-https ca-certificates
echo “deb https://download.mono-project.com/repo/ubuntu stable-xenial main” | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update

sudo apt install mono-devel

Install Duplicati
wget https://updates.duplicati.com/beta/duplicati_2.0.5.1-1_all.deb
apt install ./duplicati_2.0.5.1-1_all.deb

To Test
duplicati-server –webservice-interface=any –webservice-port=8200 –webservice-allowed-hostnames=*

Modify the following file, /etc/default/duplicati, to allow access for any IP
DAEMON_OPTS=”–webservice-interface=any –webservice-port=8200 –webservice-allowed-hostnames=*”

Add the following as /etc/systemd/system/duplicati.service
[Unit]
Description=Duplicati web-server
After=network.target

[Service]
EnvironmentFile=-/etc/default/duplicati
ExecStart=/usr/bin/duplicati-server $DAEMON_OPTS

[Install]
WantedBy=multi-user.target

To enable duplicati
systemctl enable duplicati

Check if the service is now running
systemctl status duplicati.service

If its not, try the following then check the status again
systemctl start duplicati.service

You already voted!
Leave a Comment

WordPress Error – The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

WordPress was installed on a windows machine and recently started getting this error. Seems that the web.config was modified.

To fix the error above I updated the web.config to look like this and it fixed the problem.

<configuration>
<system.webServer>
    <rewrite>
      <rules>
        <rule name="Main Rule" stopProcessing="true">
                <match url=".*" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
                <action type="Rewrite" url="/" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>
</configuration>
You already voted!
Leave a Comment