Trouble Registering ASP.Net User Controls in web.config

Posted by Community Admin on 04-Aug-2018 14:43

Trouble Registering ASP.Net User Controls in web.config

All Replies

Posted by Community Admin on 28-Jun-2011 00:00

Greetings.

Does Sitefinity support registering user controls in the web.config?  I am attempting to register my user controls under the <System.Web><Pages><Controls> node, as below, but get a runtime error.

<pages>
    <controls>
        <add tagPrefix="myPrefix" tagName="myControl" src="~/UserControls/MyControl.ascx"/>
    </controls>
</pages>

The runtime error is generated in Telerik.Sitefinity.Configuration.WebConfig.LoadTagNamespeces(XmlDocument doc):

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.

Source Error:

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.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   Telerik.Sitefinity.Configuration.WebConfig.LoadTagNamespeces(XmlDocument doc) +237
   Telerik.Sitefinity.Configuration.WebConfig..cctor() +96

[TypeInitializationException: The type initializer for 'Telerik.Sitefinity.Configuration.WebConfig' threw an exception.]
   Telerik.Sitefinity.Configuration.WebConfig.get_ResourceProviderFactoryType() +0
   Telerik.Sitefinity.Web.SiteMapBase.Initialize(String name, NameValueCollection attributes) +278
   Telerik.Sitefinity.Web.SiteMapBase.GetSiteMapProvider(String rootName) +359
   Telerik.Sitefinity.Web.SitefinityRoute.GetRouteData(HttpContextBase httpContext) +68
   System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +285
   System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +60
   System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +86
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1


Thanks!
-Valerie

Posted by Community Admin on 28-Jun-2011 00:00

Found the problem.  I had a comment inside <system.web><pages><controls>.  Once the comment was removed, the exception was no longer thrown.

<pages>
    <controls>
        <!-- Comment -->
        <add tagPrefix="myPrefix" tagName="myControl" src="~/UserControls/MyControl.ascx"/>
    </controls>
</pages>

Posted by Community Admin on 25-Apr-2014 00:00

ٍSame here and fixed by removing the commented line. Strange!!!

Anyway, thanks for your comment, really helped me :)

This thread is closed