Question

After converting my Web Site Project to a Web Application Project, some of my custom controls are missing, and I keep getting an get unrecognized element exceptions.

I can't figure out what's going on. I've tried copying over the web.config and registering the controls in the page directive, but it's still not working. Do I need to adjust the web.config manually, or is it possible that I'm still missing a reference somewhere?

I would appreciate some advice on how to fix this.

Was it helpful?

Solution

It most likely has something to do with the conversion, and I suspect the application namespace. I don't know how thorough the conversion process is, but you might need to update the user control directives and code-behind files.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyUserControl.ascx.cs" Inherits="MyNamespace.MyApplication.Controls.MyUserControl" %>

Code-behind:

namespace MyNamespace.MyApplication.Controls
{
    public partial class MyUserControl : UserControl
    {
        ...
    }
}

Also, make sure that the user controls are mapped properly in the web.config:

<pages>
    <controls>
        <add tagPrefix="Custom" src="~/controls/myusercontrol.ascx" tagName="MyUserControl" />
        ...
    </controls>
</pages>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top