How To Convert Website to Web Application

With interactive platforms steadily taking hold, more and more developers are finding the need to convert website to web application. A few programs have been built to do this, but on the whole it remains a largely manual process, at least if you’re meticulous about your work. This is true even with the most recent releases.

According to the Microsoft Developer Network, the best way to go about it is to create a new blank web application project instead of working directly from your website project. This works specifically for Visual Studio, Microsoft’s integrated development environment (IDE) and one of the most widely used today.

Once you have a blank project open, you can start moving existing items from the website. In Visual Studio, App_Code folders in the website project must be renamed, because files in this folder are compiled on the server side. This means that dropping an item onto the folder is equivalent to resetting it, because ASP.NET takes to mean there’s a new class of objects. A similar but straightforward name such as ClassFiles will do.

If you have folders containing .aspx.cs or .cs files and need to put them in the compilation, highlight the items in question, then choose Compile under Build Action on the Properties Menu. If you have any .aspx or .ascx files in your folders, make sure that Content is selected under Build Action. Next, fill in any missing project references in the Add Reference Dialog box.

If there were compilation errors in the original files in the website project, you may have to fix them manually, often file by file. You may also have to rebuild after every change, as the program doesn’t always show the errors in real time.

Partial classes are usually associated with namespaces during the creation of designer files. This means you have to surround your code with the namespaces when they come up behind partial classes. You can do this using the Surround With option in the code editor. You’ll also have to change the Page Directives so that the Inherits match the namespaces and classnames across the board. You can use tools such as Resharper to run an auto-correct sequence instead.

Next, you’ll need to recreate the original Global.asax file (if you have an existing one) because there’s no option to convert them on a web application. Replace the code from the original Global.asax file with the one from the new file, then add a new Global Application Class to recreate it. For .aspx and .ascx files, all you have to do is highlight them and use the Convert to Web Application option. Finally, stamp out any remaining errors by rebuilding the project repeatedly until it turns up clean.

Sorry, comments are closed for this post.