无法将名称中包含“-”的项目添加到 Sitecore

Not able to add Item having '-' in name to Sitecore

我正在尝试在系统中添加一种语言=>名称为 nl-Nl 的语言 但是 Sitecore 提示错误

An item name cannot contain any of the following characters:
\/:?"<>|[]- (controlled by the setting InvalidItemNameChars)

我的web.config文件有

<!--  INVALID CHARS
            Characters that are invalid in an item name
      -->
      <setting name="InvalidItemNameChars" value="\/:?&quot;&lt;&gt;|[]" />
      <!--  ITEM NAME VALIDATION
            Regular expression for validating item names
      -->
      <setting name="ItemNameValidation" value="^[\w\*$][\w\s\-$]*(\(\d{1,}\)){0,1}$" />

我可以在另一个 Sitecore 中做同样的事情而不会出现任何错误

我的 sitecore 版本是:Sitecore.NET 7.2(修订版 140526)

正如您正确识别的那样,错误是由于 InvalidItemNameChars 设置限制项目名称具有 -。您必须删除此值,添加该项目,然后重新添加设置。

由于 web.config 具有默认的 Sitecore 值,该设置将使用 patch include 进行修补,您可以在 /App_Config/Include/ 文件夹或其中一个子文件夹中找到它文件夹位于那里。检查您的 Visual Studio 项目,这将为您提供最好的线索,以准确了解哪个文件修改了该值。

可能添加了限制,并结合了 encodeNameReplacement 值,以使 URL 看起来对 SEO 友好。从长远来看,您可能需要考虑这样的事情作为更好的解决方案:https://jammykam.wordpress.com/2015/07/13/seo-friendly-urls-in-sitecore-prevention-is-better-than-cure/