Archive of ‘Uncategorized’ category

Dynamic Sitecore MVC robots.txt

Here’s a simple way to create a dynamic Sitecore MVC robots.txt.

1) RouteConfig

2. Create a RobotsController

3. Add /robots.txt to IgnoreUrlPrefixes setting in Sitecore.config

4. Ensure   <modules runAllManagedModulesForAllRequests=”true”> is set to true within web.config.


What branch is on which environment?

There is an easy way to keep tabs about what code is on each environment. There is a good MSBuild project which provides a set of useful additional MSBuild tasks:

To reference the extra tasks, you will need to make sure you have referenced the MSBuild Community Tasks Project DLL. The tasks of interest are GitVersion and GitBranch which will provide details of the SHA and branch that is being deployed. The following target is what you need to get started:

This will generate a file to App_Config/__DeployInfo which will look something like:

Similar functionality could be added for Mercurial but isn’t included in this project, the following could be useful:

Sitecore Bundles

Sitecore pipeline for implementing Microsoft.AspNet.Web.Optimization bundles. Allowing you to tie your CSS and JavaScript files to specific modules.

Cannot create Application Pools after updating Visual Studio 2013

After creating a new website in IIS (and associated AppPool) all requests return a 503 and the Application Pool is stopped.

Event Logs will have something like:

Windows cannot copy file \\?\C:\Users\Default\AppData\Local\Microsoft\VSCommon\12.0\SQM\sqmdata-7696-039-00000.sqm to location \\?\C:\Users\[App Pool Name]\AppData\Local\Microsoft\VSCommon\12.0\SQM\sqmdata-7696-039-00000.sqm. This error may be caused by network problems or insufficient security rights.
DETAIL – Access is denied.

Navigate to C:\Users\Default\AppData\Local\Microsoft\VSCommon\12.0\SQM and delete any .sqm files within the folder.

This can be traced back to installing KB2932965 which is an update for Visual Studio 2013

By default IIS 8 creates a new user profile for every AppPool identity, it does this by copying the Default user profile. For whatever reason the update creates two .sqm files without setting any read permissions. When IIS attempts to copy the default user profile it fails because it doesn’t have read access. This in turns prevents the AppPool from starting correctly (although you’d never know from the IIS Management UI)

As far as I can tell these files are for customer satisfaction metrics, if you’re feeling particularly cautious don’t delete them, just give everyone read access (but delete them).

IE11, user agent sniffing vs feature detection

I recently found a bug in curvycorners.js and IE11 – curvycorners uses user agent sniffing to detect ie browsers by looking for the presence of ‘msie’. However the IE11 user agent has changed and become far more complicated to sniff! This blog explains the changes:

User Agent sniffing seems to be a common way of detecting the browser and version in order to target code at certain browsers, however it is far from ideal. This blog gives a good overview of why it is not a good idea. It also give an overview of the alternative – feature detection

For a much more detailed blog on feature detection see: