C# – .NET WAP Publish Question – CodeFile included in publish

asp.netbuild-processcuser-controlswap

I am using a Web Application Project to develop some web user controls (c#).

In the WAP the user control directive contains the codefile and inherits attributes.

When I publish the WAP to the target website. The dll from bin is copied correctly to the bin of the website, the user controls (.ascx files) are copied correctly.

When I perform a build on the website, I get errors as the ascx files still contain the codefile attribute in the directive. To resolve this I simply remove the codefile attribute and the ascx still works as the code is picked up through the inherits (which is now in the dll).

My question is – can the publish automatically remove the codefile attribute for me. or.. am I using WAP / Build / Publish incorrectly?

Many Thanks,
Adam

Best Answer

If you are using a web application project, the aspx pages and ascx controls should use CodeBehind instead of CodeFile attribute in the page directive.