One of the customers recently asked about using the plus sign in URLs, for example:
There are at least two ways to accomplish this:
1. Allow “+” in item name via a configuration change
For this you will need to adjust the regular expression in the “ItemNameValidation” setting in web.config and make sure + sign is not present in the “InvalidItemNameChars” setting.
- Rely on the display name instead.
I personally like this approach better where you don’t need to adjust item naming rules and at the same time leverage the flexibility provided in 6.x by the dynamic link management component called “Link Manager”:
<linkManager defaultProvider="sitecore"> <providers> <clear /> <add name="sitecore" type="Sitecore.Links.LinkProvider, Sitecore.Kernel" addAspxExtension="true" alwaysIncludeServerUrl="false" encodeNames="true" languageEmbedding="asNeeded" languageLocation="filePath" shortenUrls="true" **useDisplayName="true"** /> </providers> </linkManager>
In addition to the tricks describe and , you can instruct to leverage item display names instead of item names for URLs by just flipping the “useDisplayName” parameter to “true”. This parameter is also extremely useful for multilingual sites.
Now you can change the display name of the NewsEvents item to “News+Events” and have a plus in your URL.
While everything looks great, it turned out that the request for was failing with the error below:
*Server Error in '/' Application. *
Object reference not set to an instance of an object.
*Description: *An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
*Exception Details: *System.NullReferenceException: Object reference not set to an instance of an object.
|`An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.`|
|` ` [NullReferenceException: Object reference not set to an instance of an object.] Sitecore.Nexus.Web.HttpModule.(Object sender, EventArgs e) +340 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +79 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +170 ` `|
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927
The error stack trace hinted that this is somewhere at the high level, when ’s processing is not triggered yet.
After some research on the web, I’ve found that the problem is actually related to IIS, specifically IIS7’s security filtering module which does not allow double-escaped URLs. The following configuration change addresses the problem:
<system.webServer> <security> <requestFiltering allowDoubleEscaping="true" /> </security> </system.webServer>
That's it, folks!