Use Sitecore Image Resizing even for Background-Images

Recently, I’ve looked at two Sitecore sites (not written by me!) where areas of the page (<div> tags) have a background image set by inline-CSS. For example, something like this:

Which has markup like this:

Okay, what’s wrong with this? Continue reading “Use Sitecore Image Resizing even for Background-Images”

Use Sitecore Image Resizing even for Background-Images

Chrome – OTS parsing error: invalid version tag

I saw this weird warning in Chrome’s DevTools while looking at a site:

OTS parsing error: invalid version tag

Uh-huh. That’s a bit strange. Unable to download fonts? What caused that?

Well, I tried going to the font’s URL – and got the ‘Page Not Found’ page! Well, that’s annoying – but a 404 page is clearly not a font.

However, this site’s error pages return HTTP 200 – so Chrome expects a font…

Make sure your error pages return a correct HTTP status code. If you don’t, it can cause problems. Normally, I find that it’s false positives on automated penetration tests, but this is a new and exciting variation.

Chrome – OTS parsing error: invalid version tag

Scott Helme on SSL Certificates…

Scott Helme has posted a number of interesting blog posts recently:

I mean, he’s a bit of a LetsEncrypt fan, but equally, their certificates are as good as others, and EV Certs and SSL Warranties do seem to be sources of revenue generation, rather than offering something useful.

What I’d really like is an easy way to use LetsEncrypt with IIS; for a long time it has seemed like a second-class citizen. Or maybe scripting is just more awkward in Windows. Either way, it’d be great to have simple tooling to support automatically renewing IIS site certs.

Then we could reduced certificate lifetimes and overcome the problems of the broken revocation process in certificates.

Scott Helme on SSL Certificates…

Sitecore – The type or namespace name ‘WebViewPage’ could not be found

A gentle note to myself – If I suddenly start getting errors from Sitecore of the form:

Exception: System.InvalidOperationException
Message: Error while rendering view: ‘/Views/Common/Layouts/WebLayout.cshtml’ (model: ‘Sitecore.Mvc.Presentation.RenderingModel, Sitecore.Mvc’).

or

Exception: System.Web.HttpCompileException
Message: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\4f078900\f158f9a6\App_Web_weblayout.cshtml.b31435e0.agxyl06t.0.cs(44): error CS0246: The type or namespace name ‘WebViewPage’ could not be found (are you missing a using directive or an assembly reference?)

… check that you’ve not delete the /Views/Web.config file. Again.

I keep causing this when I clear out my Views folder of old, obsolete, or test views.

Sitecore – The type or namespace name ‘WebViewPage’ could not be found

Create a self-signed certificate for development

This is a bit of an aide-memoire, based on https://blogs.msdn.microsoft.com/benjaminperkins/2017/11/15/how-to-create-a-self-signed-san-certificate-wildcard-certificate-vs-san/

The short form is, you can do this in PowerShell:

  • Open Powershell, running as administrator.
  • Run:

New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -DnsName "example.local" -FriendlyName "example.local" -NotAfter $([datetime]::now.AddYears(5))

  • Go to “Manager Computer Certificate” or run CERTMGR. You should see your certificate

Next, we want to trust this certificate. We’ll need to export it.

  • To export the certificate file you just created as a .PFX file, right click on the certificate, All Tasks -> Export…
  • When the Export menu item is selected, an export wizard is run. On the first window read through the information and click the next button.
  • In the next window, select the radio button “Yes, export the private key” and then click the next button.
  • Select Export Extended Properties, and click next
  • Set a password for the .PFX file you want to create#
  • Choose a path and export the .pfx file

Now import it into the “Trusted Root Certification Authorities” that you can see in Certificate Manager

  • Expand Trusted Root Certification Authorities –> right-click Certificates –> All Tasks –> Import.
  • Select the file you just exported. Note that you may need to change the file type to Personal Information Exchange.
  • Click Next, Fill in your file’s password, and complete the import.

That should be it completed.

Edit:

An alternative to export the cert:

Copy the Thumbprint of the cert in your Powershell window.

$pwd = ConvertTo-SecureString -String "" -Face -AsPlainText
Export-PfxCertificate -cert cert:\localMachine\my\#Thumbprint# -FilePath #FilePath# -Password $pwd

Create a self-signed certificate for development

Exposing Page Metadata in Experience Editor

Experience Editor is, ultimately, the way that editors should interact with content in pages. I mean, as a developer, I quite like Content Editor for seeing my Sitecore content…

… but editors would typically prefer something a bit more visual, something a bit more WYSIWYG. That’s a large part of the value that Sitecore give – inline editing. It’s the point of a lot of content management systems.

That’s fine, and I’ve always found the Experience Editor fairly impressive in this regard – but what do you do about content that’s not visible in the page?

A good example is page metadata – so, canonical URLs, metadata tags, browser titles (for the browser tab), etc.. You might also have a ‘summary’ or ‘thumbnail’ to use in some form of content aggregation.

Well, in the SharePoint systems I used to work with, we’d use Edit Panels in the page – that is, areas of the page that would only be shown to editors, and that would let them set these bits of text. It worked pretty well, but it was a little… awkward.

How about if we presented a dialog instead?

Continue reading “Exposing Page Metadata in Experience Editor”

Exposing Page Metadata in Experience Editor

Glass Mapper Model too deep. Potential lazy loading loop exception in a Custom LinkProvider

Okay, so the context of the issue – I’ve been asked to do some custom URL mapping in Sitecore. The customer wants some of their pages to appear at URLs other than that defined by their site structure. There’s a good article about this here, and my URL resolver is working just fine.

However, as soon as I change my link provider to my new custom one, I get the following error:

Model too deep. Potential lazy loading loop.

Okay, what is this? Well, Glass is trying to save your bacon by preventing loops of loading models. If you exceed 8 levels of depth, then it throws a wobbly. This is a good thing. Continue reading “Glass Mapper Model too deep. Potential lazy loading loop exception in a Custom LinkProvider”

Glass Mapper Model too deep. Potential lazy loading loop exception in a Custom LinkProvider