Converting a Visual Studio Web Site to a Web Application makes it easier to have control of all the references.
Here are steps todo for that procedure
- Create an empty ASP.NET application with WebForms selected
- Drag’n’drop files from the old website project into your new webapp project (except for web.config)
- On the imported .cs files change Build Action from Content to Compile
- Close Visual Studio
- For each <MyPage>.aspx.cs, <MyMaster>.master.cs and <MyControl>.ascx.cs file:
- Edit the .cs file – change CodeFile=… to CodeBehind=…
- Create an empty file called <MyPage>.aspx.designer.cs
- In the .csproj file paste link to the new file just below the include of the MyPage.aspx:
- <Compile Include=”MyPage.aspx.designer.cs”>
- Open Visual Studio
- Dran’n’drop a Label control from the Toolbox to the end of your markup
- Open the designer.cs file – now all (or most) the controls should be auto-generated in there
- Delete the label you just added from the markup
- You might have non-asp webcontrols like normal html controls where you would need to add the control in the non-designer file e.g.
protected global::System.Web.UI.HtmlControls.HtmlAnchor lnkAbout;
for a markup a hyperlink “<a href=…”
- If in doubt or lost: Create a new page or control – paste content and rename it.
- Paste content from the website web.config into the webapp web.config
- Add missing references
- Compile and run