Is a Marriage at a Foreign Consulate considered valid?

I had an inquiry recently where an individual had married at a foreign consulate in the UK and wondered whether the marriage officiated at the consulate there was valid.

In that case, the specific UK law required that, for the marriage to be valid in the UK, the building in which the consulate was located must have been designated under the Marriage Act 1994 of the UK, designating it as foreign territory, and thus legitimizing the marriage and allowing the laws of that country to apply with respect to the marriage.

According to CIC, a marriage that is legally recognized according to the law of the place where it occurs is usually recognized in Canada. The onus on applicants to prove their marriage is legal where it took place. A marriage, which took place abroad, must be valid both under the laws of the jurisdiction where it took place and under Canadian federal law. Marriages performed in embassies or consulates must meet the requirements of the host country in which the mission is located. A diplomatic mission or a consular post is considered to be within the territory and jurisdiction of the host (receiving) state. Therefore, a marriage performed in an embassy or consulate must be legally recognized by the host state in order to be valid for Canadian immigration purposes.

An applicant who married in an embassy or consulate must satisfy an officer that all of the requirements of the host country with respect to marriage have been met, including whether the host country recognizes marriages performed in diplomatic missions or consular posts within its jurisdiction.