Asp – Registering User Controls in web.config Shows Error, But Controls Work Anyway

asp.netweb.config

This has been bugging me all morning and I can't even figure out where the error is.

In the current web site I am developing (it's not a web application, in case it makes a difference, there are user controls declared as follows:

<controls>
        <add tagPrefix="uc1" tagName="TransitLinkAdmin" src="~\controls\TransitLinkAdmin.ascx"/>
        <add tagPrefix="uc1" tagName="TransitLinkList" src="~\controls\TransitLinkList.ascx"/>
        <add tagPrefix="uc1" tagName="WelcomeMessageAdmin" src="~\controls\WelcomeMessageAdmin.ascx"/>
        <add tagPrefix="uc1" tagName="WelcomeMessageDisplay" src="~\controls\WelcomeMessageDisplay.ascx"/>
        <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"/>
</controls>

So far so good, right?

But when I try to add one of these controls to a page, I get an error telling me that the control cannot be found. So why when I run the page, I can use the control?

The designer is telling me that it cannot find the user control file and it is using the path from the web.config file, so it must be looking at it in some fashion.

If I register the control directly in the page, no problems there.

My assumption (and we now how that works) is that there is some compilation error for the site as a whole that is preventing the intellisense from working.

Thanks in advance, all.

Best Answer

Just a complete guess, but maybe it is because you are using backslashes instead of forward slashes? Try:

    <add tagPrefix="uc1" tagName="TransitLinkAdmin" src="~/controls/TransitLinkAdmin.ascx"/>
    <add tagPrefix="uc1" tagName="TransitLinkList" src="~/controls/TransitLinkList.ascx"/>
    <add tagPrefix="uc1" tagName="WelcomeMessageAdmin" src="~/controls/WelcomeMessageAdmin.ascx"/>
    <add tagPrefix="uc1" tagName="WelcomeMessageDisplay" src="~/controls/WelcomeMessageDisplay.ascx"/>