Sitecore Swamp

Dive in the Sitecore Swamp


Why can't I login with Admin?


It's quite common scenario for a Sitecore consultant to spin up a environment from existing implementation. After you reset password for the Admin user, you still have the error prompt on your face:


And you checked in the database, the user ("B09BBCDE-9B3C-4DCD-B69E-67F615CE01E9") is not locked or not approved. Then there's another place can explain this:



<site name="login" virtualFolder="/sitecore/login" physicalFolder="/sitecore/login" enableAnalytics="false" database="core" domain="custom" disableXmlControls="true" />



The default domain has been changed, and you have to login with sitecore\admin rather than admin, or change domain back to sitecore.


Missing OpenSSL lib DLLs when installing MongoDB 2.6.4


For my work, I have to deal a lot of older Sitecore versions. In Sitecore 803, it needs MongoDB 2.6 according to the compatibility table. When I install MongoDB 2.6.4, an error popup: 


As read, some OpenSSL DLL files are missing from MongoDB 2.6.4 download, and it causes the problem to install on Windows 10. 


You can either download OpenSSL and find the missing DDL files there as suggested in the article. I just have it upload here (944.23 kb) (SHA1: 050967C31CE3B728038003814F43883BC2108E68)


Frequently used Regex


find duplicated lines in text, to replace with only one instance use \1\



find string which start with (



find lines which has either Script or Javascript

Sitecore MVP nomination ends today!

Want to become Sitecore MVP? Want to go Las Vegas for next year's MVP Summit? Do it now, or have to wait for another year.

You need the nomination and recommendation, and it's closing today! Go to If not already a Sitecore MVP, you also need a Sitecore employee or MVP to recommend you to qualify the nomination. 

I am going to re-nominate for Sitecore MVP 2017, wish me luck! 

Object Exporter - Visual Studio Extension

Has it happened to you that you want see and save a variable value when you doing debug in visual studio. For example, for a particular exception, you want save and share the detailed information, or you have a list of objects too difficult to watch. You can type the variable in immediate command window, and copy/paste the output, or you can use Object Exporter.

Start your debug mode, and make a break point. Now highlight the variable, and tools > Export Objects:

You can choose output format as C# Object Initialization Code, JSON and XML. Pretty cool!

Citrix Shortcuts

Citrix receiver is widely adopt as remote application access by enterprise level IT department. It enables IT deploys security polices, but compared with Microsoft Remote Desktop, it's not that easy to use with (personal feeling). Here're some shortcuts to share:

- Ctrl+F1: Ctrl+Alt+Del

- Shift+F2: exit/back to full screen mode. But, once exits from full screen mode, and back to it, you will lose all the shortcuts. So do not use this one, if you want back to the host.

- Ctrl+Alt+Del: it brings host's quick menu, and now be able to select the application icon from task bar. Click the Citrix icon in task bar to back to Citrix Receiver full screen mode, and the shortcuts still works!

The last one make need do twice if you have dual monitors, not sure if need 3 times for 3 monitors.

Glass Cast an Image Field

Today, I just encounter a scenario that I have to get the Glass Image from a Sitecore Image Field. Here's code to achieve it:

        public static Glass.Mapper.Sc.Fields.Image GlassCast(this ImageField field)
            if (field == null || field.Value.IsNullOrEmpty())
                return null;
            var glassImage = new Glass.Mapper.Sc.Fields.Image();
            Glass.Mapper.Sc.DataMappers.SitecoreFieldImageMapper.MapToImage(glassImage, field);
            return glassImage;

Happy coding.

Remove/Replace the line ending

It's quite an old problem that we have to remove the line ending and replace with <br /> somethings for web development. Everything time, I have to google the solution and trail it, and today I am going to note down the final, and no more search for the future.

First, we need understand what's line ending. It has many names: newline, end of line, line break, .. The most common we need to deal with are:

LF: \n, unix world

CR: \r some MacOS

CR+LF: \r\n, Windows

LS: 0x2028, line separator Unicode

PS: 0x2029, paragraph separator Unicode

To remove all of above instances:

        public static string ReplaceLineEndings(string value, string replaceWith)


            if (String.IsNullOrEmpty(value))


                return value;


            string pattern = @"\r\n?|[\n\u2028\u2029]";

            return Regex.Replace(value, pattern, replaceWith);


C Sharp Refreshments - Assignment Operator (=)

Coding in C#, if the most frequently typed is ;, the second should =. There's something behind the most simple operator may not known for everyone. Let's start with a simple statement:

var b = 1;

This statement will assign the value 1 to b.

int b;

var a = b = 1;

This statement will assign the value to a and b. 

How about this one:

int b;

var a = ((b = 1) == 1);

Don't question it, this is a valid c# statement, and the value of a is True. Now you may get the sense that "b=1" not only assign the value, and itself has a value. In the official C# reference of = Operator

The assignment operator (=) stores the value of its right-hand operand in the storage location, property, or indexer denoted by its left-hand operand and returns the value as its result.

Cool, now we know this, so what?