Search code examples
visual-studio-2012sitecoretagprefix

Unrecognized tag prefix or device filter 'sc' (in VS2012)


I can't get Visual Studio 2012 to recognize the 'sc' tagPrefix. My web.config contains the usual line:

<add tagPrefix="sc" namespace="Sitecore.Web.UI.WebControls"
     assembly="Sitecore.Kernel"/>

But I keep getting the Unrecognized tag prefix or device filter 'sc' message when I try to add a <sc /> tag to my page or user control.

If I open the same solution in Visual Studio 2010, it works fine.

Any ideas?


Solution

  • I finally found it. The Web.Config that is provided by Sitecore contains the following section:

    <pages validateRequest="false">
      <controls>
        <add tagPrefix="sc" namespace="Sitecore.Web.UI.WebControls" assembly="Sitecore.Kernel" />
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add tagPrefix="sc" namespace="Sitecore.Web.UI.WebControls" assembly="Sitecore.Analytics" />
      </controls>
    </pages>
    

    For VS2012, you need to remove the asp tagprefixes, so the section ends up being:

    <pages validateRequest="false">
      <controls>
        <add tagPrefix="sc" namespace="Sitecore.Web.UI.WebControls" assembly="Sitecore.Kernel" />
        <add tagPrefix="sc" namespace="Sitecore.Web.UI.WebControls" assembly="Sitecore.Analytics" />
      </controls>
    </pages>
    

    No idea why, but that solved the problem for me!

    Little side note though: after this change, it won't work in VS2010 anymore.. (neither <sc: /> nor <asp: />)