Skip to content

Month: January 2022

Custom Redirect for an HTTP 400 Bad Request in IIS

Had an issue redirecting 400 errors using httpErrors. Seems like you need to pass in existingResponse=”Replace” for it to work.

For more information : https://docs.microsoft.com/en-us/previous-versions/iis/settings-schema/ms690497(v=vs.90)

<httpErrors errorMode="DetailedLocalOnly" existingResponse="Replace">
            <remove statusCode="400" subStatusCode="-1" />
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="400" prefixLanguageFilePath="" path="https://somewhere/400.html" responseMode="Redirect" />
            <error statusCode="404" prefixLanguageFilePath="" path="https://somewhere/404.html" responseMode="Redirect" />
</httpErrors>
Leave a Comment

.NET and TLS

  • Before .NET 4.6 – TLS 1.1 is default and negotiations start down
  • .NET 4.6 – TLS 1.2 is default and negotiations start down
  • .NET 4.7 – the default value of this property is SecurityProtocolType.SystemDefault. This allows .NET Framework networking APIs based on SslStream (such as FTP, HTTP, and SMTP) to inherit the default security protocols from the operating system or from any custom configurations performed by a system administrator.
Leave a Comment

Database table location for aliases in Sitecore

Aliases in Sitecore can be found under the “SharedFields” table in the master and web databases.

FYI… I don’t recommend updating records via SQL as goes with any Sitecore data. You have to remember that there can be multiple versions of content. Use the content editor when you can.

Here is a sample query. This might not work for all cases.

select * from SharedFields sf
inner join Items i on i.id = sf.ItemId
where i.ParentID in (select ID from Items where Name = 'Aliases')
and sf.FieldId in (select ID from Items where Name = 'Linked item')

Leave a Comment

.net core api to retrieve dns records

Built a .net core api using swagger, dnsclient.net, and rollbar. Have a look here https://github.com/xavier-hernandez/dnsclient-api .

Here is the README:

I created a YAML file built on OpenAPI 3.0 standards for my endpoints(paths) and models. I generated the stub code on https://editor.swagger.io/ then tweaked, fixed, and updated the code. Creating the stub code really gives a great head start.

I kept authentication simple, it’s using an API key sent in the header request. Currently the API key is hardcoded to “1” but maybe later I’ll use a database or something to store API keys. I might host this somewhere if it’s something I find interesting to host. Tie it maybe to a MySQL/MariaDB database.

The library being used to retrieve DNS information is called DnsClient.NET https://github.com/MichaCo/DnsClient.NET and available as a nuget package.

I’m also using https://rollbar.com/ which is an easy way to log errors and information. Maybe if I host it on Azure I’ll use Application Insights.

Leave a Comment