Skip to main content

Converting a website project to a web application project

Because I had some trouble with source control integration of a website project I decided to convert it back to a web application. But how do you do this? Turns out that this is not a one step process.

The best strategy for converting an existing Web site project is to first create a new, blank Web application project in a separate directory. This avoids changing any part of the existing Web site project files. It also enables you to copy existing functionality into the new Web application project.

Step 1 -  Create a new Web application project
  1. In the File menu, click New, and then click Project.
  2. The New Project dialog box is displayed.

  3. In the Project types section of the New Project dialog box, expand the language that you want to use, and then select Web to display the Web-related templates.

  4. Select ASP.NET Empty Web Application.

  5. Type values for Name, Location, and Solution Name, and then click OK to create the Web application project.

Step 2 -Add required references to the Web application project
  1. In Solution Explorer, right-click References, and then click Add Reference.

    The Add Reference dialog box is displayed.

  2. Select the references that you want to add and then click OK.

  3. In Solution Explorer, right-click the Web application and click Build.

    Visual Studio builds the project and verifies that any project-to-project references are working.

Step 3 - Copy the Web site files to the Web application project
  1. In Solution Explorer, right-click the Web site project and select Open Folder in Windows Explorer.

  2. Select the files of the Web site project to copy.

  3. Right-click the selected files and then click Copy.

  4. In the Web application project, right-click the Web application project and click Open Folder in Windows Explorer.

  5. Paste the Web site project files into the Web application project directory.

  6. In Solution Explorer of the Web application project, click the Show All Files button.

  7. Select the new files in Solution Explorer.

  8. Right-click the selected files and then click Include In Project.

Step 4 - Converting the Project Files

Visual Studio includes an option to convert pages and classes in Web application projects to use partial classes. Partial classes are used to separate the markup in a page or user control code-behind code. These designer-generated classes are stored in a separate file from the code-behind file.

The conversion process causes Visual Studio to recursively examine every page, master page, and user control in the project, and to automatically generate a .designer.cs or .designer.vb file for each. Visual Studio also changes the .aspx or .ascx files to use the codeBehind attribute instead of the codeFile attribute. This conversion process also renames the App_Code folder to Old_App_Code.

To convert pages and classes to use partial classes in a Web application project
  1. In Solution Explorer, right-click the root project folder that contains the pages and classes that you want to convert, and then click Convert to Web Application.

  2. Build the project to see whether there are any compilation errors.

For more information, check the MSDN documentation.

Popular posts from this blog

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.

Kubernetes–Limit your environmental impact

Reducing the carbon footprint and CO2 emission of our (cloud) workloads, is a responsibility of all of us. If you are running a Kubernetes cluster, have a look at Kube-Green . kube-green is a simple Kubernetes operator that automatically shuts down (some of) your pods when you don't need them. A single pod produces about 11 Kg CO2eq per year( here the calculation). Reason enough to give it a try! Installing kube-green in your cluster The easiest way to install the operator in your cluster is through kubectl. We first need to install a cert-manager: kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.5/cert-manager.yaml Remark: Wait a minute before you continue as it can take some time before the cert-manager is up & running inside your cluster. Now we can install the kube-green operator: kubectl apply -f https://github.com/kube-green/kube-green/releases/latest/download/kube-green.yaml Now in the namespace where we want t

DevToys–A swiss army knife for developers

As a developer there are a lot of small tasks you need to do as part of your coding, debugging and testing activities.  DevToys is an offline windows app that tries to help you with these tasks. Instead of using different websites you get a fully offline experience offering help for a large list of tasks. Many tools are available. Here is the current list: Converters JSON <> YAML Timestamp Number Base Cron Parser Encoders / Decoders HTML URL Base64 Text & Image GZip JWT Decoder Formatters JSON SQL XML Generators Hash (MD5, SHA1, SHA256, SHA512) UUID 1 and 4 Lorem Ipsum Checksum Text Escape / Unescape Inspector & Case Converter Regex Tester Text Comparer XML Validator Markdown Preview Graphic Color B