ASP.NET Custom Control - Unknown server tag

前端 未结 5 1731
自闭症患者
自闭症患者 2020-12-15 03:00

I\'ve made a custom control that inherits from a Literal control. When I try and use my control on a page a parsing error is thrown. I\'ve added this to my web.config

<
5条回答
  •  不思量自难忘°
    2020-12-15 03:48

    I was receiving the "Unknown server tag" error for a user control that was part of my project. There was no external assembly. @citronas mentioned that "If this does not work, your control probably can't compile.", and that is also listed as the most likely cause in this troubleshooting post.

    Although my control code was compiling without errors, it turned out that there were warnings that I was ignoring. My warnings were regarding a resource file that was in my control folder that was referencing another missing file. Once I addressed the warnings, then the control compiled correctly and I was able to use the control with just a Register directive and no modifications to web.config, like this:

    <%@ Register TagPrefix="myPrefix" TagName="myControl" Src="~/controls/mySourceFile.ascx" %>
    
    
    

提交回复
热议问题