Sitecore MVC Error

You have just started with Sitecore MVC and might have watched a very good series of videos by Martina Welander. If not you can get started with them at,

Sitecore MVC – Getting Started (Part 1)
Sitecore MVC — View Renderings, @Html.Sitecore(), and Custom Models (Part 2)

The point to write this post is after watching Part 1 video, I was still not able to run sitecore MVC on my machine. The obvious reason being, Martina’s video are for older version of Sitecore MVC whereas I was working on sitecore 7.2 and MVC 5.

The issue that I faced was,
Could not load file or assembly ‘System.Web.Mvc’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

sitecore mvc-1

Above error itself is self-explanatory and says something about mismatch of “System.Web.Mvc.dll” or one of its dependency.

Hence I checked the properties of in my website bin folder and there the catch was. Instead of version 5.1 it was 4.0 version of the System.Web.Mvc.dll

sitecore mvc-4

Also it is known that sitecore 7.2 supports MVC so I decided to install MVC 5 on my sitecore solution.

How to install MVC 5?

Different version of MVC can be installed using Package Manager Console available in Visual Studio IDE -> Tools -> Nuget Package Manager. I referred to Microsoft ASP.NET MVC 5.1.2 page for installation of MVC. This link also has information about other version of MVC and their installation.

sitecore mvc-2

Before installing MVC 5, your sitecore solution should be opened as it installs MVC specific to your project otherwise you will encounter the below error.

sitecore mvc-3

For installing MVC execute below command,
Install-Package Microsoft.AspNet.Mvc -Version 5.1.2

MVC 5 should now be installed. Do a web publish from you visual studio IDE and your sitecore site should now be up and running.

Finally to be sure check the properties of “System.Web.Mvc.dll” file it would have now been changed to 5.1.

sitecore mvc-5

More blogs on Sitecore MVC Errors

–          Preparing Sitecore 7.2 and MVC in Visual Studio 2013 by Martin Davis

Site Under Maintenance – Sum

Introduction

Site Under Maintenance – SUM allows to place your sitecore website under maintenance mode and display a healthy message to your website visitors. This module come in handy while you might be carrying out maintenance, deployments, fixing defects, upgrading your website, moving or restructuring your content.

SUM is also available on sitecore marketplace. Download SUM from marketplace.

Background

We had a request from one of our client to have a maintenance page while we were deploying changes for a rebranding. The requirement was to keep the sitecore content manager available in the background but the internet facing website should display a maintenance message. Content delivery and manager were on the same sitecore instance and on a single IIS website. One might think of using the standard procedure of placing the APP_Offline.htm in the root directory of the website which allows to display a maintenance page. However this will also bring down the access to content manager. Hence changing of content and publishing might not be possible.

The other option, a bit complicated and tedious is to have two websites with same host header as the live one, yes definitely one site would be in stop mode. Then as required these two sites can be switched on / off once the maintenance is over.

I thought to have a more sophisticated way for achieving this and came up with SUM.

Features

– Supports single and multi-site sitecore instance.
– The maintenance page can be built using your own layouts and sub layouts to match your site theme.
– Multi lingual maintenance page.
– Option to turn on/off the maintenance mode.
– Content delivery and content manager server is same or separate.
– Easily installed as a sitecore package.
– Can be plugged with Sitecore 6.4 to 7.2.

Installation

Installation of SUM is quick and easy, it is bundled up as a standard sitecore package. It can be downloaded from Github repository here. The package includes following items and code files,

1) Items

• /sitecore/content/Home/Standard-Items/
• /sitecore/content/Home/Standard-Items/Site-Maintenance/
• /sitecore/content/Site-Settings/
• /sitecore/layout/Sublayouts/SUM/
• /sitecore/layout/Sublayouts/SUM/Maintenance Sublayout/
• /sitecore/media library/Images/SUM/
• /sitecore/media library/Images/SUM/site-under-maintenance-1/
• /sitecore/templates/SUM/
• /sitecore/templates/SUM/Site-Maintenance/__Standard Values/
• /sitecore/templates/SUM/Site-Maintenance/
• /sitecore/templates/SUM/Site-Maintenance/Site Maintenance/
• /sitecore/templates/SUM/Site-Maintenance/Site Maintenance/MaintenanceContent/
• /sitecore/templates/SUM/Site-Maintenance/Site Maintenance/MaintenanceImage/
• /sitecore/templates/SUM/Site-Settings/__Standard Values/
• /sitecore/templates/SUM/Site-Settings/
• /sitecore/templates/SUM/SUM-Data-Template/
• /sitecore/templates/SUM/SUM-Data-Template/Site Maintenance/
• /sitecore/templates/SUM/SUM-Data-Template/Site Maintenance/MaintenanceLink/
• /sitecore/templates/SUM/SUM-Data-Template/Site Maintenance/SwitchSUM/

2) Code files

• /bin/SUM.Pipelines.dll
• /App_config/Include/sum.config
• /layouts/sublayout/Maintenance.ascx

How to install SUM?

SUM comes as a standard sitecore package and can be installed using Installation Wizard from Sitecore Desktop. Follow below steps for installation of SUM,
Before starting the installation make sure the pop-blocker for your site is disabled.
1) Open Installation Wizard from Sitecore Desktop
2) Upload Site maintenance – SUM-1.0.zip
3) Click Next
4) Click Finish
5) On Installation Wizard dialog you will see Site Maintenance – SUM-1.0.zip package, now click Next
6) Click Install
7) Click Finish, the installation of SUM is now finished, next follow configuration section of this document.

Configuration

Changes to your website’s web.config file is not required as it is taken care by /App_config/Includes/sum.config. This module uses Include File Patching Facilities technique hence no manual configuration is required.
You can verify the configuration changes by using /sitecore/admin/showconfig.aspx where SUM.Pipelines processor would have been added before ExecuteRequest processor.
How to disable SUM?
In case you need to disable SUM module, you should rename /App_config/Includes/sum.config to /App_config/Includes/sum.config.disable, the standard way sitecore suggests for disabling any config file.

Limitation

Site-Setting items needs to be sibling of StartItem for a site.

Technical Implementation

1. SiteMaintenance Pipeline

The pipeline checks for the context site, startitem and finds the site-settings item, a sibling of start item. On the site-settings item it performs a check on SwitchSum field for the maintenance page to be on / off. If the switch is off -> do nothing and exits the pipeline. If switch is on it will take the maintenance page link from “MaintenanceLink” field and redirects to it.
Note: Site-Setting item needs to be sibling of home item.

SUM-Maintenance field

2. SwitchSUM Field

This field is responsible for making the maintenance page on / off. It is kept shared field deliberately as in case of multi-lingual site, maintenance page should appear for all languages.

3. MaintenanceLink Field

Sum pipeline will redirect to a page that will be selected in this field.

4. Maintenance Sublayout

It give the flexibility of changing the image and content based on the theme of a site.

Source

Complete code for SUM is shared and available on GitHub at SUM. You can download it and modify as per your needs also.
Sitecore package is also available on GitHub as SUM – Sitecore package.

Implementation scenarios

1) Single Site

Below is an example scenario and architecture of content tree where SUM can be helpful for single site instance.SUM-Single Site

2) Multi-Site

Below is an example scenario and architecture of content tree where SUM can be helpful for multi-site instance.SUM-Multi Site

Single Sign On (SSO)- Sitecore

Introduction

In most cases, if an organization has the domain controller set up, the workstations are usually included into a domain. Imagine that you have established a connection between the Managers organization unit and your Sitecore CMS installation. This means that the members of this organization unit are now able to work in Sitecore CMS according to their roles. Naturally, these users wish to be logged in to Sitecore CMS automatically.

The other implementation of SSO can be for an Organization’s intranet site where in, once the user is logged into a domain the intranet site should authenticate them and display sections of the sites based on their roles.

So if you are looking for SSO implementation with Sitecore for above scenarios this post might be helpful.

In order to implement SSO you will need to install Active Directory Module on your Sitecore CMS. For more details about installing and configuring active directory module you can visit my earlier post “Active Directory Module and Sitecore”.

Prerequisites

There are some prerequisites for using this functionality:

  • User’s workstation must be a member of the appropriate domain.
  • The anonymous access must be disabled to the /sitecore/admin/ldaplogin.aspx page and the Integrated Windows security mode must be turned on.

Configuration Steps

1. IIS 6

In order to disable the anonymous access in IIS 6, follow the steps below:

  • Start IIS.
  • Expand the target website.
  • Navigate to the /sitecore/admin folder and select the LDAPLogin.aspx page.
  • Right-click the LDAPLogin.aspx page and select Properties.

Switch to the File Security tab, uncheck the anonymous access checkmark.

As a result, the IIS configuration should look similar to this:

sso1

2. IIS 7 or higher

The configuration of IIS 7 or higher differs a bit.

To begin with, IIS 7 does not support mixed authentication mode. Hence you cannot have several authentication types enabled for you site.

Hence for Windows Authentication you have to disable Forms authentication (which is default for Sitecore installation) and enable Windows Authentication for your site, as shown below

sso2

Next step is pretty straightforward. You have to go to the AD login page and disable anonymous access for that page, as shown below:

sso3

Now, when the prerequisites are satisfied, you can login to Sitecore CMS with your system account without providing the user credentials manually. So, run the following URL in your browser: http://[yoursite]/sitecore/admin/LDAPLogin.aspx

Note

You can still login in the usual way by addressing the default Sitecore shell login page (http://[yoursite]/sitecore)

Errors & Resolutions

Below sections explains few errors and resolutions in case single sign on do not work.

    1. If you did forget to verify the prerequisites and your machine appeared not to be in a domain or the anonymous access has not been removed from the login page, the system will not log you in, displaying the reason of the refuse.sso4
    2. Some errors may occur when the system begins to analyze user credentials. For instance, if the domain name is correct, and you’re a member of the Active Directory domain, but you’re not a member of the Managers organization unit which is plugged into Sitecore, you’ll get the following warning.sso5
    3. It may happen that the real domain name differs from the domain name entered in Sitecore CMS. For instance, you may be a user of the Active Directory domain called “Company.com”, but this very domain is plugged into Sitecore CMS as “ad” (which is done by default). In such case, the system won’t reject your attempt to login, but will iterate the existent Sitecore CMS domains trying to find the appropriate user. If the user is still not found, the following warning will be displayed.sso6
    4. In case when the user is found in Active Directory domain, but it doesn’t have enough permissions to login to Sitecore CMS shell interface (the user is not included in the sitecore\Sitecore Client Users role), the system will reject the login attempt and display the following message.sso7
    5. Once you have passed through the above errors and still you are not able to login using SSO, there is a post “401.1 error + anonymos access + multiple host headers” by Alex Shyba on SDN, below is the extract from the post.This mostly happens in development environments, in case of production or staging servers where Sitecore is installed on other machine you just need to add the site to your list of Intranet sites.The problem can be reproduced if you add some host headers for your site in IIS (5.1 or 6.0) and disable anonymous access for the whole site. Let’s assume that you have two host headers added (test and test.mydomain). Disable anonymous login and try to access the site using test and test.mydomain.As a result, you have the IIS login prompting window shown. After specifying the correct(!) login credentials, you are not able to authenticate and get nothing but the 401.1 error screen in IE. Note that using the localhost host header doesn’t cause any problems, however.For development environment the solution is to hack into Windows registry and add some keys. You can find official instructions here:
      http://support.microsoft.com/default.aspx?scid=kb;en-us;896861In
      <br/ >In order to make this annoying window disappear, you should add those sites (test and test.mydomain) to the list of Local intranet sites in IE.And finally if everything is fine and the user is allowed to login, you’ll be logged in automatically and redirected to Sitecore Content Editor.
    6. Single Sign On issue in sitecore 7.2

      In sitecore 7.2 when we hit http://[yoursite]/sitecore/admin/LDAPLogin.aspx, it does authenticate the user, there are entries in log file confirming successful login of a user, but does not redirect the user to content editor and takes the user back to /sitecore/login/ page. It is a bug in Active Directory Module. A ticket was raised by me to sitecore support # 410076 the solution provided by sitecore support is as below.

      a. Copy Sitecore.Support.403767.dll in your website bin folder.

      b. Change the inherited type for the /sitecore/admin/ldaplogin.aspx page as below:

      <%@ Page Language=”C#” AutoEventWireup=”true” Inherits=”LightLDAP.Support.LDAPLogin,Sitecore.Support.403767″ %>