+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Trouble Registering ASP.Net User Controls in web.config

Trouble Registering ASP.Net User Controls in web.config

3 posts, 0 answered
  1. Valerie
    Valerie avatar
    19 posts
    Registered:
    24 Mar 2010
    28 Jun 2011
    Link to this post
    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
  2. Valerie
    Valerie avatar
    19 posts
    Registered:
    24 Mar 2010
    28 Jun 2011
    Link to this post
    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>
  3. Mohammad Elsheimy
    Mohammad Elsheimy avatar
    1 posts
    Registered:
    13 Oct 2012
    25 Apr 2014 in reply to Valerie
    Link to this post

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

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

3 posts, 0 answered