When we register our User Controls in web.config instead of on the page, we found the type is generated as System.Web.UI.UserControl instead of the type of the actual user control. Here are the steps to reproduce this problem:
1) Create a new Web Site
2) Create a folder called Controls and add a user control to this folder (e.g., WebUserControl.ascx)
3) Add a web.config to the site
4) Add the control registration to the web.config. E.g.:
<pages>
<controls>
<add tagPrefix="test" tagName="WebUserControl" src="~/Controls/WebUserControl.ascx"/>
</controls>
</pages>
5) Add an instance of the user control to default.aspx:
<test:WebUserControl runat="server" ID="test" />
6) Add a Web Application Project to the solution. Delete default.aspx and web.config from the new project. Copy the Controls folder, Default.aspx, and web.config to the new project.
7) Right click on the new Web Application project and select "Convert To Web Application"
8) Take a look at Default.aspx.designer.cs. We expect to see:
protected Controls_WebUserControl test;
But instead we get:
protected System.Web.UI.UserControl test;
Let's try moving the control registration to the page itself.
9) Remove the "pages" section from the web.config
10) Add the control registration to default.aspx:
<%@ Register TagPrefix="test" TagName="WebUserControl" Src="~/Controls/WebUserControl.ascx" %>
11) Delete Default.aspx.designer.cs. Right click Default.aspx and select "Convert to Web Application"
12) Take a look at Default.aspx.designer.cs. We get what we expected:
protected Controls_WebUserControl test123;
So basically whenever we register controls in our web.config, we get the wrong type in the .designer.cs file. In our project we have a number of commonly used controls registered in web.config so unless there is a workaround or fix, we cannot use WAP. I should mention that I tried many different variations on the path for the src attribute ("/", "~/", "./", etc).
Please let me know if there is a solution for this. Thanks.